Exemple #1
0
        /// <summary>
        /// otestuje zda prislusny bot lezi na oblouku
        /// </summary>
        /// <param name="pt">testovany bod</param>
        /// <returns></returns>
        public bool IsPointOn(Point pt)
        {
            Circle2D?c = GetAngles(out double st, out double an);

            if (c == null)
            {
                return(false);
            }
            if (!Funcs2D.Distance(pt, c.Value.Center).IsEqual(Math.Abs(Radius)))
            {
                return(false);
            }
            st = Funcs2D.PureRadianAngle(st);
            double angle = Funcs2D.LineAngle(c.Value.Center, pt);

            if (an > 0)
            {
                an = st + an;
                return(angle.IsGreaterOrEqual(st) && angle.IsLesserOrEqual(an));
            }
            else
            {
                an = st + an;
                return(angle.IsGreaterOrEqual(an) && angle.IsLesserOrEqual(st));
            }
        }
Exemple #2
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) });
        }
Exemple #3
0
 /// <summary>
 /// otestuje zda poloprimka zadaneho smeru protne oblouk
 /// </summary>
 /// <param name="angle">uhel poloprimky</param>
 /// <returns></returns>
 public bool IsAngleOn(double angle)
 {
     if (GetAngles(out double st, out double an) == null)
     {
         return(false);
     }
     angle = Funcs2D.PureRadianAngle(angle);
     if (an > 0)
     {
         an = st + an;
         return(angle.IsGreaterOrEqual(st) && angle.IsLesserOrEqual(an));
     }
     else
     {
         an = st + an;
         return(angle.IsGreaterOrEqual(an) && angle.IsLesserOrEqual(st));
     }
 }