Saga3D API Documentation
1.0-RC4
|
Go to the documentation of this file.
5 #ifndef __IRR_AABBOX_3D_H_INCLUDED__
6 #define __IRR_AABBOX_3D_H_INCLUDED__
31 aabbox3d(T minx, T miny, T minz, T maxx, T maxy, T maxz):
MinEdge(minx, miny, minz),
MaxEdge(maxx, maxy, maxz) {}
64 void reset(
const glm::vec3& initValue)
121 const T radius =
getExtent().getLength() / 2;
137 return e.x * e.y * e.z;
144 return 2*(e.x*e.y + e.x*e.z + e.y*e.z);
152 const glm::vec3 diag = middle -
MaxEdge;
167 edges[0] = { middle.x + diag.x, middle.y + diag.y, middle.z + diag.z };
168 edges[1] = { middle.x + diag.x, middle.y - diag.y, middle.z + diag.z };
169 edges[2] = { middle.x + diag.x, middle.y + diag.y, middle.z - diag.z };
170 edges[3] = { middle.x + diag.x, middle.y - diag.y, middle.z - diag.z };
171 edges[4] = { middle.x - diag.x, middle.y + diag.y, middle.z + diag.z };
172 edges[5] = { middle.x - diag.x, middle.y - diag.y, middle.z + diag.z };
173 edges[6] = { middle.x - diag.x, middle.y + diag.y, middle.z - diag.z };
174 edges[7] = { middle.x - diag.x, middle.y - diag.y, middle.z - diag.z };
199 float inv = 1.0f - d;
280 const glm::vec3& linevect, T halflength)
const
282 const glm::vec3 e =
getExtent() * (T)0.5;
283 const glm::vec3 t =
getCenter() - linemiddle;
285 if ((fabs(t.x) > e.x + halflength * fabs(linevect.x)) ||
286 (fabs(t.y) > e.y + halflength * fabs(linevect.y)) ||
287 (fabs(t.z) > e.z + halflength * fabs(linevect.z)))
290 T r = e.y * (T)fabs(linevect.z) + e.z * (T)fabs(linevect.y);
291 if (fabs(t.y*linevect.z - t.z*linevect.y) > r)
294 r = e.x * (T)fabs(linevect.z) + e.z * (T)fabs(linevect.x);
295 if (fabs(t.z*linevect.x - t.x*linevect.z) > r)
298 r = e.x * (T)fabs(linevect.y) + e.y * (T)fabs(linevect.x);
299 if (fabs(t.x*linevect.y - t.y*linevect.x) > r)
315 if (plane.
Normal.x > (T)0)
321 if (plane.
Normal.y > (T)0)
327 if (plane.
Normal.z > (T)0)
333 if (plane.
Normal.dotProduct(nearPoint) + plane.
D > (T)0)
336 if (plane.
Normal.dotProduct(farPoint) + plane.
D > (T)0)
Template plane class with some intersection testing methods.
void repair()
Repairs the box.
aabbox3d< std::int32_t > aabbox3di
Typedef for an integer 3d bounding box.
T getLength() const
Get length of line.
bool intersectsWithBox(const aabbox3d< T > &other) const
Determines if the axis-aligned box intersects with another axis-aligned box.
T getRadius() const
Get radius of the bounding sphere.
bool isPointInside(const glm::vec3 &p) const
Determines if a point is within this box.
EIntersectionRelation3D classifyPlaneRelation(const plane3d< T > &plane) const
Classifies a relation with a plane.
bool operator==(const aabbox3d< T > &other) const
Equality operator.
void addInternalPoint(T x, T y, T z)
Adds a point to the bounding box.
glm::vec3 MinEdge
The near edge.
aabbox3d< T > getInterpolated(const aabbox3d< T > &other, float d) const
Calculates a new interpolated bounding box.
EIntersectionRelation3D
Enumeration for intersection relations of 3d objects.
glm::vec3 getExtent() const
Get extent of the box (maximal distance of two points in the box)
bool isEmpty() const
Check if the box is empty.
3D line between two points with intersection methods.
aabbox3d< T > intersect(const aabbox3d< T > &other) const
Returns the intersection of this box with another, if possible.
aabbox3d< float > aabbox3df
Typedef for a float 3d bounding box.
aabbox3d()
Default Constructor.
T getArea() const
Get the surface area of the box in squared units.
bool intersectsWithLine(const line3d< T > &line) const
Tests if the box intersects with a line.
Axis aligned bounding box in 3d dimensional space.
aabbox3d(T minx, T miny, T minz, T maxx, T maxy, T maxz)
Constructor with min edge and max edge as single values, not vectors.
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
glm::vec3 getVector() const
Get vector of line.
void getEdges(glm::vec3 *edges) const
Stores all 8 edges of the box into an array.
bool operator!=(const aabbox3d< T > &other) const
Inequality operator.
aabbox3d(const glm::vec3 &init)
Constructor with only one point.
bool intersectsWithLine(const glm::vec3 &linemiddle, const glm::vec3 &linevect, T halflength) const
Tests if the box intersects with a line.
T getVolume() const
Get the volume enclosed by the box in cubed units.
glm::vec3 getCenter() const
Get center of the bounding box.
const T & max_(const T &a, const T &b)
returns maximum of two values. Own implementation to get rid of the STL (VS6 problems)
void addInternalBox(const aabbox3d< T > &b)
Adds another bounding box.
glm::vec3 MaxEdge
The far edge.
bool isFullInside(const aabbox3d< T > &other) const
Check if this box is completely inside the 'other' box.
void addInternalPoint(const glm::vec3 &p)
Adds a point to the bounding box.
void reset(const aabbox3d< T > &initValue)
Resets the bounding box.
const T & min_(const T &a, const T &b)
returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)
aabbox3d(const glm::vec3 &min, const glm::vec3 &max)
Constructor with min edge and max edge.
glm::vec3 getMiddle() const
Get middle of line.
glm::vec3 Normal
Normal vector of the plane.
void reset(const glm::vec3 &initValue)
Resets the bounding box to a one-point box.
bool isPointTotalInside(const glm::vec3 &p) const
Determines if a point is within this box and not its borders.