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];
80 if(!verts)
return 0.0f;
82 if(P==0.0
f)
return 0.0f;
83 return (4.0
f*
PI*
Area(verts)/(P*P));
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]];
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]];
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);
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;
472 *nearvtx = mVRef[d.SmallestAxis()];
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;
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;
bool BackfaceCulling(const Point *verts, const Point &source) const
void GetVRefs(ubyte edgenb, udword &vref0, udword &vref1, udword &vref2) const
bool Equal(const IndexedTriangle &tri) const
inline_ float Magnitude() const
Computes magnitude.
udword mVRef[3]
Vertex-references.
void DenormalizedNormal(const Point *verts, Point &normal) const
float Perimeter(const Point *verts) const
float ComputeOcclusionPotential(const Point *verts, const Point &view) const
float Angle(const IndexedTriangle &tri, const Point *verts) const
void Center(const Point *verts, Point ¢er) const
float Area(const Point *verts) const
unsigned int udword
sizeof(udword) must be 4
void CenteredNormal(const Point *verts, Point &normal) const
float MinEdgeLength(const Point *verts) const
unsigned char ubyte
sizeof(ubyte) must be 1
#define MAX_FLOAT
max possible float value
float Compacity(const Point *verts) const
bool IsDegenerate() const
void Normal(const Point *verts, Point &normal) const
bool IsVisible(const Point *verts, const Point &source) const
bool ReplaceVertex(udword oldref, udword newref)
inline_ float UnitRandomFloat()
Returns a unit random floating-point value.
void RandomPoint(const Point *verts, Point &random) const
float MaxEdgeLength(const Point *verts) const
bool HasVertex(udword ref) const
ubyte FindEdge(udword vref0, udword vref1) const
#define INVALID_ID
Invalid dword ID (counterpart of null pointers)
inline_ float SquareDistance(const Point &b) const
Computes square distance to another point.
#define MIN_FLOAT
min possible loat value
inline_ float Distance(const Point &b) const
Computes distance to another point.
void ComputePoint(const Point *verts, float u, float v, Point &pt, udword *nearvtx=null) const
udword OppositeVertex(udword vref0, udword vref1) const
*inline_ void Swap(udword &x, udword &y)