private static int ComputeOutCode(float x, float y, float minX, float minY, float maxX, float maxY)
        {
            int code = 0;

            if (x.ApproxEqual(minX) || x.ApproxEqual(maxX))
            {
            }
            else if (x < minX)
            {
                code |= 0x1;
            }
            else if (x > maxX)
            {
                code |= 0x2;
            }

            if (y.ApproxEqual(minY) || x.ApproxEqual(maxY))
            {
            }
            else if (y < minY)
            {
                code |= 0x4;
            }
            else if (y > maxY)
            {
                code |= 0x8;
            }
            return(code);
        }
Example #2
0
 public static float IntersectParabolaX(float focus1X, float focus1Y, float focus2X, float focus2Y,
                                        float directrix)
 {
     //admittedly this is pure voodoo.
     //there is attached documentation for this function
     return(focus1Y.ApproxEqual(focus2Y)
         ? (focus1X + focus2X) / 2
         : (focus1X * (directrix - focus2Y) + focus2X * (focus1Y - directrix) +
            (float)Math.Sqrt((directrix - focus1Y) * (directrix - focus2Y) *
                             ((focus1X - focus2X) * (focus1X - focus2X) +
                              (focus1Y - focus2Y) * (focus1Y - focus2Y))
                             )
            ) / (focus1Y - focus2Y));
 }
Example #3
0
 public static bool ApproxLessThanOrEqualTo(this float value1, float value2)
 {
     return(value1 < value2 || value1.ApproxEqual(value2));
 }
Example #4
0
 public static bool ApproxGreaterThanOrEqualTo(this float value1, float value2)
 {
     return(value1 > value2 || value1.ApproxEqual(value2));
 }