Пример #1
0
        // vypocita rovnobeznou primku
        public static Point[] LineOffset(Point pt1, Point pt2, double offset)
        {
            Vector vv = pt2.Minus(pt1),             // vektor
                   nv = Funcs2D.VectorNormal(vv);   // kolmy vektor

            Point[] ret = new Point[2];
            if (Funcs2D.IsNull(vv))
            {
                ret[0] = pt1;
                ret[1] = pt2;
                return(ret);
            }
            ;

            double len = vv.Length,                     // delka primky
                   kn  = offset / len;                  // delkovy koeficient offsetu

            // prvni bod
            ret[0].X = pt1.X + (kn * nv.X);
            ret[0].Y = pt1.Y + (kn * nv.Y);

            // druhy bod
            ret[1].X = ret[0].X + vv.X;
            ret[1].Y = ret[0].Y + vv.Y;

            return(ret);
        }
Пример #2
0
        public static Point LineRelPtOffset(Point pt1, Vector vv, double rel, double offset)
        {
            Point  ret = new Point();
            Vector nv  = Funcs2D.VectorNormal(vv);                       // kolmy vektor

            if (Funcs2D.IsNull(vv))
            {
                return(ret);
            }

            double len = vv.Length,                           // delka primky
                   kn  = offset / len;                        // delkovy koeficient offsetu
            Point pt   = PointOnLine(pt1, vv, rel);

            ret.X = pt.X + (kn * nv.X);
            ret.Y = pt.Y + (kn * nv.Y);

            return(ret);
        }
Пример #3
0
 public bool IsNull()
 {
     return(Funcs2D.IsNull(myVc));
 }