33 using System.Runtime.InteropServices;
37 [StructLayout(LayoutKind.Sequential, Size = LineSegment.Size)]
38 [AdvBrowsableOrder(
"Vertex1,Vertex2")]
39 #if !CompactFramework && !WindowsCE && !PocketPC && !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !NETFX_CORE
50 div = 1 / ((v4.Y - v3.Y) * (v2.X - v1.X) - (v4.X - v3.X) * (v2.Y - v1.Y));
51 ua = ((v4.X - v3.X) * (v1.Y - v3.Y) - (v4.Y - v3.Y) * (v1.X - v3.X)) * div;
52 ub = ((v2.X - v1.X) * (v1.Y - v3.Y) - (v2.Y - v1.Y) * (v1.X - v3.X)) * div;
53 result = ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1;
58 div = 1 / ((v4.Y - v3.Y) * (v2.X - v1.X) - (v4.X - v3.X) * (v2.Y - v1.Y));
59 ua = ((v4.X - v3.X) * (v1.Y - v3.Y) - (v4.Y - v3.Y) * (v1.X - v3.X)) * div;
60 ub = ((v2.X - v1.X) * (v1.Y - v3.Y) - (v2.Y - v1.Y) * (v1.X - v3.X)) * div;
61 if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1)
83 Vector2D.
Dot(ref normal, ref ray.Direction, out dir);
89 Vector2D.
Dot(ref normal, ref originDiff, out actualDistance);
90 Scalar DistanceFromOrigin = -(actualDistance / dir);
91 if (DistanceFromOrigin >= 0)
94 Vector2D.
Multiply(ref ray.Direction, ref DistanceFromOrigin, out intersectPos);
95 Vector2D.
Add(ref intersectPos, ref originDiff, out intersectPos);
98 Vector2D.
Dot(ref intersectPos, ref tanget, out distanceFromSecond);
100 if (distanceFromSecond >= 0 && distanceFromSecond <= edgeMagnitude)
102 result = DistanceFromOrigin;
119 Scalar nProj = local.
Y * edge.X - local.X * edge.Y;
120 Scalar tProj = local.X * edge.X + local.Y * edge.Y;
125 else if (tProj > edgeLength)
132 result = Math.Abs(nProj);
144 Scalar nProj = local.
Y * edge.X - local.X * edge.Y;
145 Scalar tProj = local.X * edge.X + local.Y * edge.Y;
148 result = tProj * tProj + nProj * nProj;
150 else if (tProj > edgeLength)
153 result = tProj * tProj + nProj * nProj;
157 result = nProj * nProj;
166 [InstanceConstructor(
"Vertex1,Vertex2")]
169 this.Vertex1 = vertex1;
170 this.Vertex2 = vertex2;
211 return Equals(ref
this, ref other);
215 return Equals(ref line1, ref line2);
224 return Equals(ref line1, ref line2);
228 return !
Equals(ref line1, ref line2);