コード例 #1
0
ファイル: Line2.cs プロジェクト: aarondandy/vertesaur
 /// <inheritdoc/>
 public bool Equals(Line2 other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(P.Equals(other.P) &&
            Direction.Equals(other.Direction));
 }
コード例 #2
0
ファイル: Segment2.cs プロジェクト: aarondandy/vertesaur
        /// <summary>
        /// Determines the if a point <paramref name="p"/> intersects a line segment defined by <paramref name="a"/> and <paramref name="b"/>.
        /// </summary>
        /// <param name="a">An end point of a segment.</param>
        /// <param name="b">An end point of a segment.</param>
        /// <param name="p">A point.</param>
        /// <returns>True when a point intersects a line segment.</returns>
        [Pure] public static bool Intersects(Point2 a, Point2 b, Point2 p)
        {
            if (p.Equals(a) || p.Equals(b))
            {
                return(true);
            }
            Point2.Order(ref a, ref b);
            var d    = b - a;
            var v    = p - a;
            var aDot = d.Dot(v);

            return(
                (aDot <= 0)
                ? (0 == v.X && 0 == v.Y)
                : (
                    !(aDot >= d.GetMagnitudeSquared()) &&
                    (d.X * v.Y) - (d.Y * v.X) == 0.0
                    )
                );
        }
コード例 #3
0
ファイル: Ray2.cs プロジェクト: aarondandy/vertesaur
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <returns>
 /// <c>true</c> if the current object is equal to the <paramref name="other"/> parameter; otherwise, <c>false</c>.
 /// </returns>
 /// <param name="other">An object to compare with this object.</param>
 public bool Equals(Ray2 other)
 {
     return(!ReferenceEquals(null, other) &&
            P.Equals(other.P) &&
            Direction.Equals(other.Direction));
 }
コード例 #4
0
ファイル: Segment2.cs プロジェクト: aarondandy/vertesaur
 /// <inheritdoc/>
 public bool Equals(Segment2 other)
 {
     return(!ReferenceEquals(null, other) &&
            A.Equals(other.A) &&
            B.Equals(other.B));
 }