Ejemplo n.º 1
0
        /// <summary>
        /// Calculates the intersection point of two segments
        /// </summary>
        /// <param name="other">The line to intersect with this one.</param>
        /// <param name="segment">Segment intersection; the point must be contained in the line segment. If not contained, the returned Vector has int.MaxValue.</param>
        /// <returns></returns>
        public virtual Vector2 IntersectionPoint(Segment2D other)
        {
            Vector2 point = base.IntersectionPoint(other);

            if (float.IsNaN(point.x) || float.IsInfinity(point.x))
            {
                return(new Vector2(float.NaN, float.NaN));
            }

            if (Contains(point) && other.Contains(point))
            {
                return(point);
            }

            return(new Vector2(float.NaN, float.NaN));
        }
Ejemplo n.º 2
0
 public virtual bool Intersects(Segment2D segment) {
     Vector2 point = IntersectionPoint(segment);
     return !point.IsNaN() && !point.IsInfinity() && Contains(point) && segment.Contains(point);
 }
Ejemplo n.º 3
0
 public Segment2D(Segment2D original) : base(original)
 {
     MiddlePoint = original.MiddlePoint;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Calculates the intersection point of this segment with the segment AB.
        /// </summary>
        /// <param name="other">The line to intersect with this one.</param>
        /// /// <returns></returns>
        public override Vector2 IntersectionPoint(Vector2 pointA, Vector2 pointB)
        {
            Segment2D segment = new Segment2D(pointA, pointB);

            return(this.IntersectionPoint(segment));
        }