|
Core 1.0
|
Convex polytopes with fixed normals, also referred to as k-topes. More...
#include <ktope.h>
Public Member Functions | |
| KTope () | |
| Empty. | |
| KTope (const Vector &) | |
| Creates a single vertex k-tope. | |
| KTope (const Box &) | |
| Creates a k-tope bounding a box. | |
| KTope & | operator+= (const Vector &) |
| Adds a vertex to the k-tope structure. | |
| Vector | Normal (int) const |
| Returns the i-th normal of the k-tope. | |
| bool | Intersect (const Ray &, double &, double &) const |
| Compute the intersection between a k-tope and a ray parametrized by its origin and direction vectors. Sorted intersection depths are returned if intersection occurs. | |
| bool | Inside (const Vector &) const |
| Check if a point is inside the KTope. | |
| bool | Intersect (const KTope &) const |
| Check if two k-topes intersect. | |
| KTope | operator+ (const KTope &) const |
| Computes the bounding k-tope of the union of two k-topes. | |
| KTope | Scale (const double &) const |
| Scale a k-tope. | |
Protected Attributes | |
| double | c [18] = { 0.0 } |
| Array of constants defining the planes. | |
Convex polytopes with fixed normals, also referred to as k-topes.
This version implements a 18-polytope, which performs the fastest for a variety of applications. Refer to Klosowki, Efficient collision detection using bounding volumes hierarchies of k-dops, IEEE Transactions on Visualisation and Computer Graphics, 4(1), 1998.
The class stores the offset corresponding to the fixed normal directions.
This class implements some useful functions, such as the intersection between a k-tope and a ray.
|
explicit |
Creates a single vertex k-tope.
| v | Point. |
|
explicit |
Creates a k-tope bounding a box.
The offsets of the 18 planes are tight: the offset of the plane of normal n is the opposite of the largest value of n.p over the eight vertices of the box, so that the diagonal planes touch the box along its edges. Planes which are not set would pass through the origin.
| box | The box. |
| bool KTope::Inside | ( | const Vector & | p | ) | const |
Check if a point is inside the KTope.
| p | Point. |
| bool KTope::Intersect | ( | const KTope & | k | ) | const |
Check if two k-topes intersect.
The planes come in pairs with opposite normals: the projection of a k-tope on the direction normals[i+1] is the interval [c[i],-c[i+1]] (for i even), which is the slab defined by the two planes. Two k-topes cannot intersect if the intervals of one of the pairs of planes are disjoint. The k-topes are therefore intersecting if all the intervals overlap, which is a conservative test: it never misses an intersection, but may accept k-topes which are disjoint although none of the slabs separates them.
| k | Argument k-tope. |
| bool KTope::Intersect | ( | const Ray & | ray, |
| double & | tmin, | ||
| double & | tmax ) const |
Compute the intersection between a k-tope and a ray parametrized by its origin and direction vectors. Sorted intersection depths are returned if intersection occurs.
| ray | The ray. |
| tmin,tmax | Intersection depths. |
Computes the bounding k-tope of the union of two k-topes.
This is not the Minkowski sum: for every plane, the less restrictive coefficient of the two k-topes is kept.
| b | Argument k-topes. |
Adds a vertex to the k-tope structure.
This function does not modify the k-tope if the point lies inside the k-tope, otherwise plane coefficients are updated accordingly.
| p | Point. |
| KTope KTope::Scale | ( | const double & | a | ) | const |
Scale a k-tope.
| a | Real. |