47 location[0] = loc0[0];
48 location[1] = loc0[1];
56 location[0] = loc1[0];
57 location[1] = loc1[1];
61 if ((e0i == 1) && (e1i == 1))
63 if ((loc0[0] - p).mag2() < (loc1[0] - p).mag2())
65 location[0] = loc0[0];
66 location[1] = loc1[0];
70 location[0] = loc1[0];
71 location[1] = loc0[0];
82 location[0] = loc2[0];
83 location[1] = loc2[1];
87 if ((e0i == 0) && (e1i == 0) && (e2i == 0))
return false;
89 if ((e0i == 1) && (e2i == 1))
91 if ((loc0[0] - p).mag2() < (loc2[0] - p).mag2())
93 location[0] = loc0[0];
94 location[1] = loc2[0];
98 location[0] = loc2[0];
99 location[1] = loc0[0];
104 if ((e1i == 1) && (e2i == 1))
106 if ((loc1[0] - p).mag2() < (loc2[0] - p).mag2())
108 location[0] = loc1[0];
109 location[1] = loc2[0];
113 location[0] = loc2[0];
114 location[1] = loc1[0];
152 double kross =
Cross(d0, d1);
153 double sqrKross = kross * kross;
154 double sqrLen0 = d0.
mag2();
155 double sqrLen1 = d1.
mag2();
166 double ss =
Cross(e, d1) / kross;
167 if (ss < 0)
return 0;
168 double t =
Cross(e, d0) / kross;
169 if (t < 0 || t > 1)
return 0;
175 location[0] = p0 + ss * d0;
182 double sqrLenE = e.
mag2();
183 kross =
Cross(e, d0);
184 sqrKross = kross * kross;
193 double s0 = d0.
dot(e) / sqrLen0;
194 double s1 = s0 + d0.
dot(d1) / sqrLen0;
209 if (smax < 0.0)
return 0;
213 location[1] = p0 + smax * d0;
218 location[0] = p0 + smin * d0;
219 location[1] = p0 + smax * d0;
227 return v1.
x * v2.
y - v1.
y * v2.
x;
static bool IntersectLineAndTriangle2D(const UVector2 &p, const UVector2 &v, const UVector2 &p0, const UVector2 &e0, const UVector2 &e1, UVector2 location[2])
static double Cross(const UVector2 &v1, const UVector2 &v2)
static int IntersectLineAndLineSegment2D(const UVector2 &p0, const UVector2 &d0, const UVector2 &p1, const UVector2 &d1, UVector2 location[2])
double dot(const UVector2 &p) const