Exemplo n.º 1
0
        public Side GetSide(Vector2D pt)
        {
            return((Side)Math.Sign(StartToEnd.Cross(pt - Start)));

            /*
             * //its the basic idea of the crossproduct in R3 with a garuanteed 0 for z.
             * return (Side)Math.Sign(Start.X * (End.Y - pt.Y) + End.X * (pt.Y - Start.Y) + pt.X * (Start.Y - End.Y));*/
        }
Exemplo n.º 2
0
        public float GetIntersectionRatio(Vector2D start, Vector2D dir)
        {
            //see IsIntersecting...
            Vector2D s = Start - start;

            float denom = StartToEnd.Cross(dir);

            return(dir.Cross(s) / denom);
        }
Exemplo n.º 3
0
        /**
         * Returns the sample ratio where this line would intersect the other. Segment boundaries are not considered.
         */
        public float GetIntersectionRatio(LineSegment2D other)
        {
            //see IsIntersecting...
            Vector2D ov = other.StartToEnd;
            Vector2D s  = Start - other.Start;

            float denom = StartToEnd.Cross(ov);

            return(ov.Cross(s) / denom);
        }
Exemplo n.º 4
0
 /**
  * Compare this line segment to another and return true if the lines are parallel.
  */
 public bool IsParallel(LineSegment2D other, float tolerance = 0)
 {
     return(Math.Abs(StartToEnd.Cross(other.StartToEnd)) <= tolerance);
 }