Esempio n. 1
0
        public static double[] AnglesCrossLine(Point centre, double r, Point pt1, Point pt2)
        {
            Point t = Funcs2D.PointToLine(pt1, pt2, centre);

            if (Funcs2D.IsEqual(t, centre))
            {
                double an = Funcs2D.LineAngle(pt1, pt2);
                return(new double[] { Funcs2D.PureRadianAngle(an + Math.PI), an });
            }
            double z = Funcs2D.Distance(centre, t);
            double a = Funcs2D.LineAngle(centre, t);

            if (z.IsGreater(r))
            {
                return(null);             // mimo
            }
            if (z.IsEqual(r))             // tecna
            {
                return(new double[] { a });
            }

            //secna
            double aa = Math.Acos(z / r);             // uhel pulky tetivy

            return(new double[] { Funcs2D.PureRadianAngle(a + aa), Funcs2D.PureRadianAngle(a - aa) });
        }
Esempio n. 2
0
        public static ParallelResult ParallelCheck(
            Point pta, Vector da,          //bod a vektor prvni primky
            Point ptb, Vector db,          //bod a vektor druhe primky
            out Point retRel,              // vraci relativni souradnice ( x = begin, y = end) na prvni primce
            out bool direct)               // smer vektoru primek, true stejny smer, false opacny smer
        {
            retRel = new Point();
            direct = false;
            var rr = Funcs2D.IsParallel(da, db);

            if (rr == 0)
            {
                return(ParallelResult.Nothing);
            }
            direct = rr > 0;

            retRel.X = Funcs2D.PointToLine(pta, da, ptb);
            retRel.Y = Funcs2D.PointToLine(pta, da, ptb.Plus(db));

            if (Funcs2D.IsThreePointsOnLine(pta, pta.Plus(da), ptb))
            {
                return(ParallelResult.ParallelOn);
            }
            else
            {
                return(ParallelResult.ParallelOut);
            }
        }