34 Swap(mVRef[1], mVRef[2]);
46 if(!verts)
return 0.0f;
47 const Point& p0 = verts[0];
48 const Point& p1 = verts[1];
49 const Point& p2 = verts[2];
50 return ((p0-p1)^(p0-p2)).Magnitude() * 0.5f;
62 if(!verts)
return 0.0f;
63 const Point& p0 = verts[0];
64 const Point& p1 = verts[1];
65 const Point& p2 = verts[2];
66 return p0.Distance(p1)
80 if(!verts)
return 0.0f;
81 float P = Perimeter(verts);
82 if(P==0.0
f)
return 0.0f;
83 return (4.0
f*
PI*Area(verts)/(P*P));
97 const Point& p0 = verts[mVRef[0]];
98 const Point& p1 = verts[mVRef[1]];
99 const Point& p2 = verts[mVRef[2]];
100 normal = ((p2-p1)^(p0-p1)).Normalize();
114 const Point& p0 = verts[mVRef[0]];
115 const Point& p1 = verts[mVRef[1]];
116 const Point& p2 = verts[mVRef[2]];
117 normal = ((p2-p1)^(p0-p1));
131 const Point& p0 = verts[mVRef[0]];
132 const Point& p1 = verts[mVRef[1]];
133 const Point& p2 = verts[mVRef[2]];
134 center = (p0+p1+p2)*
INV3;
148 const Point& p0 = verts[mVRef[0]];
149 const Point& p1 = verts[mVRef[1]];
150 const Point& p2 = verts[mVRef[2]];
151 Point Center = (p0+p1+p2)*
INV3;
152 normal = Center + ((p2-p1)^(p0-p1)).Normalize();
170 float OneOverTotal = 1.0f / (Alpha + Beta + Gamma);
171 Alpha *= OneOverTotal;
172 Beta *= OneOverTotal;
173 Gamma *= OneOverTotal;
175 const Point& p0 = verts[mVRef[0]];
176 const Point& p1 = verts[mVRef[1]];
177 const Point& p2 = verts[mVRef[2]];
178 random = Alpha*p0 + Beta*p1 + Gamma*p2;
192 if(!verts)
return false;
194 const Point& p0 = verts[mVRef[0]];
195 const Point& p1 = verts[mVRef[1]];
196 const Point& p2 = verts[mVRef[2]];
199 Point Normal = (p2 - p1)^(p0 - p1);
202 return (Normal | source) >= 0.0f;
220 if(!verts)
return false;
222 const Point& p0 = verts[mVRef[0]];
223 const Point& p1 = verts[mVRef[1]];
224 const Point& p2 = verts[mVRef[2]];
230 Point Normal = (p2 - p1)^(p0 - p1);
234 return (Normal | (source - p0)) >= 0.0
f;
251 if(!verts)
return 0.0f;
258 float A = Area(verts);
259 Point N; Normal(verts, N);
260 Point C; Center(verts, C);
261 float d =
view.Distance(C);
262 return -(A*(N|
view))/(d*d);
275 if(mVRef[0]==oldref) { mVRef[0] = newref;
return true; }
276 else if(mVRef[1]==oldref) { mVRef[1] = newref;
return true; }
277 else if(mVRef[2]==oldref) { mVRef[2] = newref;
return true; }
289 if(mVRef[0]==mVRef[1])
return true;
290 if(mVRef[1]==mVRef[2])
return true;
291 if(mVRef[2]==mVRef[0])
return true;
304 if(mVRef[0]==ref)
return true;
305 if(mVRef[1]==ref)
return true;
306 if(mVRef[2]==ref)
return true;
320 if(mVRef[0]==ref) { *index = 0;
return true; }
321 if(mVRef[1]==ref) { *index = 1;
return true; }
322 if(mVRef[2]==ref) { *index = 2;
return true; }
336 if(mVRef[0]==vref0 && mVRef[1]==vref1)
return 0;
337 else if(mVRef[0]==vref1 && mVRef[1]==vref0)
return 0;
338 else if(mVRef[0]==vref0 && mVRef[2]==vref1)
return 1;
339 else if(mVRef[0]==vref1 && mVRef[2]==vref0)
return 1;
340 else if(mVRef[1]==vref0 && mVRef[2]==vref1)
return 2;
341 else if(mVRef[1]==vref1 && mVRef[2]==vref0)
return 2;
355 if(mVRef[0]==vref0 && mVRef[1]==vref1)
return mVRef[2];
356 else if(mVRef[0]==vref1 && mVRef[1]==vref0)
return mVRef[2];
357 else if(mVRef[0]==vref0 && mVRef[2]==vref1)
return mVRef[1];
358 else if(mVRef[0]==vref1 && mVRef[2]==vref0)
return mVRef[1];
359 else if(mVRef[1]==vref0 && mVRef[2]==vref1)
return mVRef[0];
360 else if(mVRef[1]==vref1 && mVRef[2]==vref0)
return mVRef[0];
408 if(!verts)
return 0.0f;
411 float Length01 = verts[0].Distance(verts[1]);
412 float Length02 = verts[0].Distance(verts[2]);
413 float Length12 = verts[1].Distance(verts[2]);
414 if(Length01 < Min) Min = Length01;
415 if(Length02 < Min) Min = Length02;
416 if(Length12 < Min) Min = Length12;
429 if(!verts)
return 0.0f;
432 float Length01 = verts[0].Distance(verts[1]);
433 float Length02 = verts[0].Distance(verts[2]);
434 float Length12 = verts[1].Distance(verts[2]);
435 if(Length01 > Max) Max = Length01;
436 if(Length02 > Max) Max = Length02;
437 if(Length12 > Max) Max = Length12;
456 const Point& p0 = verts[mVRef[0]];
457 const Point& p1 = verts[mVRef[1]];
458 const Point& p2 = verts[mVRef[2]];
461 pt = (1.0f - u - v)*p0 + u*p1 + v*p2;
467 Point d(p0.SquareDistance(pt),
468 p1.SquareDistance(pt),
469 p2.SquareDistance(pt));
472 *nearvtx = mVRef[d.SmallestAxis()];
483 float Angle(
const Point& u,
const Point& v)
485 float NormU = u.Magnitude();
486 float NormV = v.Magnitude();
487 float Product = NormU*NormV;
488 if(Product==0.0
f)
return 0.0f;
489 float OneOverProduct = 1.0f / Product;
492 float Cosinus = (u|v) * OneOverProduct;
496 float NormW = w.Magnitude();
498 float AbsSinus = NormW * OneOverProduct;
501 if(AbsSinus > 1.0
f) AbsSinus = 1.0f;
502 if(AbsSinus < -1.0
f) AbsSinus = -1.0f;
504 if(Cosinus>=0.0
f)
return asinf(AbsSinus);
505 else return (
PI-asinf(AbsSinus));
519 if(!verts)
return 0.0f;
528 if(dp>1.0
f)
return 0.0f;
529 if(dp<-1.0
f)
return PI;
545 return (HasVertex(tri.
mVRef[0]) &&
546 HasVertex(tri.
mVRef[1]) &&
547 HasVertex(tri.
mVRef[2]));