71 #include "linesegment.h"
74 #include "MathTools/mathtools.h"
83 isect0 = VV0 + ( VV1 - VV0 ) * D0 / ( D0 - D1 );
84 isect1 = VV0 + ( VV2 - VV0 ) * D0 / ( D0 - D2 );
95 isect(VV2,VV0,VV1,D2,D0,D1,isect0,isect1);
96 }
else if( D0D2 > 0.0 ) {
98 isect(VV1,VV0,VV2,D1,D0,D2,isect0,isect1);
99 }
else if( D1 * D2 > 0.0f || D0 != 0.0 ) {
101 isect(VV0,VV1,VV2,D0,D1,D2,isect0,isect1);
102 }
else if( D1 != 0.0 ) {
103 isect(VV1,VV0,VV2,D1,D0,D2,isect0,isect1);
104 }
else if( D2 != 0.0 ) {
105 isect(VV2,VV0,VV1,D2,D0,D1,isect0,isect1);
137 case 0:
return this->
PointA;
break;
138 case 1:
return this->
PointB;
break;
139 case 2:
return this->
PointC;
break;
150 case 0:
return this->
PointA;
break;
151 case 1:
return this->
PointB;
break;
152 case 2:
return this->
PointC;
break;
187 for(
short i = 0 ; i < 3; i++ )
190 if( i == 0 ) Vec = Other.
PointA;
191 else if( i == 1 ) Vec = Other.
PointB;
192 else if( i == 2 ) Vec = Other.
PointC;
194 if( MathTools::Abs( du[i] ) < 1e-6 )
198 Real du0du1 = du[0] * du[1];
199 Real du0du2 = du[0] * du[2];
201 if( du0du1 > 0.0 && du0du2 > 0.0 )
212 for(
short i = 0 ; i < 3 ; i++ )
215 if( i == 0 ) Vec = this->
PointA;
216 else if( i == 1 ) Vec = this->
PointB;
217 else if( i == 2 ) Vec = this->
PointC;
219 if( MathTools::Abs( dv[i] ) < 1e-6 )
223 Real dv0dv1 = dv[0] * dv[1];
224 Real dv0dv2 = dv[0] * dv[2];
226 if( dv0dv1 > 0.0 && dv0dv2 > 0.0 )
239 Real Max = MathTools::Abs( d[0] );
241 Real b = MathTools::Abs( d[1] );
242 Real c = MathTools::Abs( d[2] );
249 Real vp0 = this->PointA[index];
260 ComputeIntervals(vp0,vp1,vp2,dv[0],dv[1],dv[2],dv0dv1,dv0dv2,isect1[0],isect1[1]);
263 ComputeIntervals(up0,up1,up2,du[0],du[1],du[2],du0du1,du0du2,isect2[0],isect2[1]);
265 if( isect1[0] > isect1[1] )
266 std::swap(isect1[0],isect1[1]);
267 if( isect2[0] > isect2[1] )
268 std::swap(isect2[0],isect2[1]);
270 if( isect1[1] < isect2[0] || isect2[1] < isect1[0] )
274 Real r1 = std::max( isect1[0], isect2[0] );
275 Real r2 = std::min( isect1[1], isect2[1] );
282 Vector3 v1 = p + d * ( ( r1 - p[index] ) / d[index] );
283 Vector3 v2 = p + d * ( ( r2 - p[index] ) / d[index] );
292 case 0:
return this->
PointA;
break;
293 case 1:
return this->
PointB;
break;
294 case 2:
return this->
PointC;
break;
305 case 0:
return this->
PointA;
break;
306 case 1:
return this->
PointB;
break;
307 case 2:
return this->
PointC;
break;
Vector3 PointA
The first point in space making the triangle.
Vector3 CrossProduct(const Vector3 &Vec) const
This is used to calculate the crossproduct of this and another vector.
Triangle2D()
Blank constructor.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
int Integer
A datatype used to represent any integer close to.
LineSegment3D GetOverlap(const Triangle3D &Other) const
Gets the overlap of two triangles.
Ray GetOverlap(const Plane &Other) const
Gets the overlap of two Planes expressed as a Ray.
This is used to represent a flat infinite slice of the game world.
This implements the exception hiearchy for Mezzanine.
float Real
A Datatype used to represent a real floating point number.
A geometry math class for expressing a line connecting 2 points in 3D space.
Vector2 PointC
The third point in space making the triangle.
This is used to represent a point on a 2 dimentional area, such as a screen.
Vector2 & operator[](const Whole &Index)
Gets the point in this triangle corresponding to the specified index. the index passed in is greater ...
const Vector3 & GetOrigin() const
Gets the origin of this ray.
Vector3 & operator[](const Whole &Index)
Gets the point in this triangle corresponding to the specified index. the index passed in is greater ...
Vector3 & Normalize()
This will change this point into it's own normal relative to the origin.
A geometry math class for expressing a triangle in 3D space.
Vector3 PointC
The third point in space making the triangle.
Thrown when a passed parameter is checked at runtime and not in the expected range.
Vector3 PointB
The second point in space making the triangle.
Vector2 PointB
The second point in space making the triangle.
Real DotProduct(const Vector3 &Vec) const
This is used to calculate the dotproduct of this and another vector.
Real SquaredLength() const
Gets the length of this vector squared.
This is used to represent a point in space, or a vector through space.
Triangle3D()
Blank constructor.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Vector2 PointA
The first point in space making the triangle.
This represents a line placed in 3D space and is used with spacial queries.