Exemplo n.º 1
0
        /// <summary>
        /// Set if a point is in the right/left of a vector
        /// return true if the OB is right of OA
        /// </summary>
        /// <param name="orig"></param>
        /// <param name="A"></param>
        /// <param name="B"></param>
        /// <returns></returns>
        public static Boolean SideTest(IVertex<float> orig, IVertex<float> A, IVertex<float> B)
        {
            //// check if the node acceptable
            IVertex<float> a = A.Copy();
            a.Subtract(ref orig);

            IVertex<float> b = B.Copy();
            b.Subtract(ref orig);

            #if true
            a.Normalize();
            b.Normalize();
            double cross = a.X * b.Y - a.Y * b.X;

            #else

            double cross = Math.Atan2(b.Y, b.X) - Math.Atan2(a.Y, a.X);
            cross += (cross + Math.PI <= 0.00001) ? 2 * Math.PI : 0;
            cross -= (cross - Math.PI >= -0.00001) ? 2 * Math.PI : 0;

            #endif

            return cross < -0.0001;
        }