Beispiel #1
0
        public Line(Point origin, Point direction)
            : this()
        {
            Origin    = origin;
            Direction = direction;

            Normal = direction.Perp();
            Ax     = Normal.X;
            By     = Normal.Y;
            C      = Point.Dot(-PointAtDistance((Real)1.0), Normal);
        }
Beispiel #2
0
        public static int DetermineSide(Line line, Point normal, Point point)
        {
            Real value = Point.Dot(line.Normal, point) + line.C;

            if (Math.Abs(value) < MathHelper.Epsilon)
            {
                return(0);
            }
            else if (value < 0)
            {
                return(-1);
            }
            else //if (value > 0)
            {
                return(1);
            }
        }
Beispiel #3
0
 public static Line FromTwoPoints(Point point1, Point point2)
 {
     return(new Line(point1, point2 - point1));
 }
Beispiel #4
0
 public static int DetermineSide(Line line, Point point)
 {
     return(DetermineSide(line, line.Normal, point));
 }
Beispiel #5
0
 public Point PointAtDistance(Real distance)
 {
     return(Origin + distance * Point.Normalize(Direction));
 }
Beispiel #6
0
 /// <summary>
 /// Returns a positive number if c is to the left of the line going from a to b.
 /// </summary>
 /// <returns>Positive number if point is left, negative if point is right,
 /// and 0 if points are collinear.</returns>
 public static double Area(ref Point a, ref Point b, ref Point c)
 {
     return(a.X * (b.Y - c.Y) + b.X * (c.Y - a.Y) + c.X * (a.Y - b.Y));
 }
Beispiel #7
0
 /// <summary>
 /// Returns a positive number if c is to the left of the line going from a to b.
 /// </summary>
 /// <returns>Positive number if point is left, negative if point is right,
 /// and 0 if points are collinear.</returns>
 public static double Area(Point a, Point b, Point c)
 {
     return(Area(ref a, ref b, ref c));
 }
Beispiel #8
0
 public static bool Collinear(ref Point a, ref Point b, ref Point c, double tolerance)
 {
     return(MathHelper.DoubleInRange(Area(ref a, ref b, ref c), -tolerance, tolerance));
 }
Beispiel #9
0
 /// <summary>
 /// Determines if three vertices are collinear (ie. on a straight line)
 /// </summary>
 /// <param name="a">First vertex</param>
 /// <param name="b">Second vertex</param>
 /// <param name="c">Third vertex</param>
 /// <returns></returns>
 public static bool Collinear(ref Point a, ref Point b, ref Point c)
 {
     return(Collinear(ref a, ref b, ref c, 0));
 }