Esempio n. 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);
        }
Esempio n. 2
0
        /// <summary>
        /// vytvori oblouk zadany pocatecnim bodem, vektorem ve kterm je koncovy bod a zdvihem v poloine usecky
        /// </summary>
        /// <param name="pt1">pocatecni bod oblouku</param>
        /// <param name="v">vektor udavajici koncovy bod oblouky</param>
        /// <param name="elevation">zdvih oblouku v polovine usecky [pt1,v]</param>
        /// <returns></returns>
        public static Arc2D Arc2DElevation(Point pt1, Vector v, double elevation)
        {
            Point pt2, pt3 = pt1.Plus(v);

            pt2 = Funcs2D.PointOnLineLen(Funcs2D.PointOnLine(pt1, v, 0.5), Funcs2D.VectorNormal(v), elevation);
            return(new Arc2D(pt1, pt2, pt3));
        }
Esempio n. 3
0
        //vypocita kolmy prumet bodu na usecce , vysledek je relativni souradnice usecky
        public static double PointToLine(Point pt1, Vector v, Point pk)
        {
            Vector vn = Funcs2D.VectorNormal(v);

            TwoLine2D.CrossRel(pt1, v, pk, vn, out Point ret);

            return(ret.X);
        }
Esempio n. 4
0
        public static IPolygonReader[] PolygonsInterconnect(IPolygonReader[] polygons, Point pt, Vector v)
        {
            IPolygonReader[] ret = null;
            List <Tuple <double, int, int> > cr = new List <Tuple <double, int, int> >();

            bool[] bcr  = new bool[polygons.Length];
            Point  ptt  = new Point();
            Vector norm = Funcs2D.VectorNormal(v);

            for (int i = 0; i < polygons.Length; i++)
            {
                for (int j = 0; j < polygons[i].Length; j++)
                {
                    polygons[i].GetRow(j, out double x, out double y);
                    ptt.X = x; ptt.Y = y;
                    if (TwoLine2D.CrossRel(pt, v, ptt, norm, out Point pr))
                    {
                        if (Funcs2D.IsEqual(pr.Y, 0.0, Funcs2D.Epson))
                        {
                            cr.Add(new Tuple <double, int, int>(pr.X, i, j));
                            bcr[i] = true;
                        }
                    }
                }
            }
            if (cr.Count < 2)
            {
                return(null);
            }
            int k = 1;

            foreach (var b in bcr)
            {
                if (!b)
                {
                    k++;
                }
            }
            ret = new IPolygonReader[k];
            k   = 0;
            for (int i = 0; i < bcr.Length; i++)
            {
                if (!bcr[i])
                {
                    ret[k++] = polygons[i];
                }
            }

            // trideni
            cr.Sort((a, b) => a.Item1.CompareTo(b.Item1));

            List <Point> rpt = new List <Point>();

            f_InterconnectJoin(0, cr, polygons, rpt);

            ret[k] = new BoxListPoint(Funcs2D.PolygonPure(new BoxListPoint(rpt), true));
            return(ret);
        }
Esempio n. 5
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);
        }