|
Core 1.0
|
A plane defined by its analytic equation. More...
#include <plane.h>
Public Member Functions | |
| Plane () | |
| Empty. | |
| Plane (const Vector &, const double &) | |
| Creates a plane given normal and distance. | |
| Plane (const Vector &, const Vector &) | |
| Creates a plane given normal and vertex. | |
| Plane (const Vector &) | |
| Creates a plane given normal passing through the origin. | |
| ~Plane () | |
| Empty. | |
| bool | Intersect (const Ray &, double &) const |
| Compute the intersection between a plane and a ray. | |
| bool | Inside (const Vector &) const |
| Check if a point is inside or outside the plane. | |
| int | Side (const Vector &) const |
| Check if a point lies inside, outside or even on the plane. | |
| Vector | Normal () const |
| Returns the normal to the plane. | |
| Vector | Vertex () const |
| Finds a vertex on the plane. | |
| double | Coeff () const |
| Returns the coefficient of the plane. | |
| double | R (const Vector &) const |
| Compute the squared distance to the half space delimited by the plane. | |
| double | Signed (const Vector &) const |
| Compute the signed distance between a point and the plane. | |
| double | Eval (const Vector &) const |
| Evaluates the equation of the plane. | |
| void | Transform (const Matrix4 &) |
| Transforms a plane given an affine homogeneous transformation matrix. The normal is transformed by the inverse transpose of the linear part of the matrix, which is valid for non uniform scaling and shearing. | |
| void | Translate (const double &) |
| Translates a plane in the direction of its normal. | |
| void | Rotate (const Matrix &) |
| Rotate a plane. | |
| void | Scale (const double &) |
| Scale a plane. | |
| Vector | Symmetry (const Vector &) const |
| Compute the point symmetric to the argument point. | |
| Box | Symmetric (const Box &) const |
| Compute the bounding box of the symmetric argument box. | |
| Segment | Symmetric (const Segment &) const |
| Compute the symmetric segment. | |
| Sphere | Symmetric (const Sphere &) const |
| Compute the symmetric sphere. | |
| Vector | Reflect (const Vector &) const |
| Compute the reflected direction. | |
| bool | Refract (const Vector &, const double &, Vector &) const |
| Compute the refracted direction. | |
| Vector | Intersect (const Line &) const |
| Compute the intersection between a plane and a line. | |
| bool | Intersect (const Segment &, double &) const |
| Compute the intersection between a plane and a segment. | |
| Quadric | Equation (const Ray &) const |
| Compute the quadric equation of the Euclidean distance to the plane. | |
| Frame | GetFrame () const |
| Return a Frame attached to the plane. | |
| Axis | Intersect (const Plane &) const |
| Compute the intersection between two planes. | |
Static Public Member Functions | |
| static void | Cast (const Vector &, double &, double &) |
| Compute the inverse mapping coordinates of a point. | |
| static Vector | Intersection (const Plane &, const Plane &, const Plane &) |
| Compute the intersection between three planes. | |
| static QVector< Vector > | ConvexPoints (const QVector< Plane > &) |
| Compute the intersection of a set of half spaces. | |
| static Vector | Reflect (const Vector &, const Vector &) |
| Given an input (normalized) normal, compute a reflected direction. The code is the same as: | |
| static bool | Refract (const Vector &, const Vector &, const double &, Vector &) |
| Compute the refracted direction. | |
Static Public Attributes | |
| static const double | epsilon = 1e-06 |
| Small value for checking intersection with a ray. | |
| static const Plane | XY |
| Reference z-axis horizontal plane. | |
| static const Plane | YZ |
| Reference x-axis plane. | |
| static const Plane | ZX |
| Reference y-axis plane. | |
Protected Attributes | |
| Vector | n = Vector::Z |
| Plane normal. | |
| double | cqc = 0.0 |
| Plane coefficient. | |
Friends | |
| std::ostream & | operator<< (std::ostream &s, const Plane &plane) |
| Overloaded. | |
A plane defined by its analytic equation.
This class serves as a base core class for binary space patitionning or constructive solid geometry in ray-tracing.
|
inlineexplicit |
Creates a plane given normal and distance.
The equation of the plane is: \(\ep \cdot \en - c = 0\).
| n | Normal, should be unit. |
| c | Plane constant. |
Creates a plane given normal and vertex.
| n | Plane normal, should be unit. |
| p | Any point on the plane. |
|
explicit |
Creates a plane given normal passing through the origin.
| n | Plane normal, should be unit. |
|
static |
Compute the inverse mapping coordinates of a point.
| p | Point that will be projected on the plane. |
| u,v | Returned coordinates. |
Compute the intersection of a set of half spaces.
This is a O(n^4) algorithm
A better version in O(n^3) could be implemented: see Finding the Intersection of Half-Spaces in Time O(n ln n). Preparata and Muller, Theoretical Computer Science 8, 45-55, 1979.
Returns a set of point representing the minimal convex polygon embedding all half spaces. The function doesn't check if the intersection is bounded or not.
| planes | Set of planes. |
Compute the quadric equation of the Euclidean distance to the plane.
| ray | The ray. |
|
inline |
Evaluates the equation of the plane.
This can be interpreted as a signed distance to the plane.
| p | Point. |
| Frame Plane::GetFrame | ( | ) | const |
Return a Frame attached to the plane.
| bool Plane::Inside | ( | const Vector & | p | ) | const |
Check if a point is inside or outside the plane.
This function compares the sign strictly to 0.0, use Plane::Side() for a more fuzzy implementation.
| p | Point. |
Compute the intersection between a plane and a line.
The line should not be parallel to the plane.
| l | The line. |
Compute the intersection between two planes.
The planes should not be parallel, otherwise the result is not defined. The normals of the planes do not need to be normalized.
The axis is directed by the cross product of the normal of this plane and the normal of the argument plane. Its origin is the point of the intersection line which is the closest to the origin.
| plane | Argument plane. |
| bool Plane::Intersect | ( | const Ray & | ray, |
| double & | t ) const |
Compute the intersection between a plane and a ray.
The intersection depth is returned if intersection occurs.
| ray | The ray. |
| t | Intersection depth. |
| bool Plane::Intersect | ( | const Segment & | s, |
| double & | t ) const |
Compute the intersection between a plane and a segment.
The intersection point can be computed using Segment::Vertex(const double&) if intersection occurs.
| s | The segment. |
| t | Position of the point if intersection occurs. |
Compute the intersection between three planes.
Returns Vector::Null if two planes are complanar.
| a,b,c | Three planes. |
| double Plane::R | ( | const Vector & | p | ) | const |
Compute the squared distance to the half space delimited by the plane.
| p | Point. |
Compute the reflected direction.
| d | Direction. |
Compute the refracted direction.
| d | Direction. |
| eta | Index of incoming ray medium divided by the index of the other material. |
| r | Refracted direction. |
Compute the refracted direction.
| d | Direction. |
| n | Normal. |
| eta | Index of incoming ray medium divided by the index of the other material. |
| r | Refracted direction. |
| void Plane::Rotate | ( | const Matrix & | r | ) |
Rotate a plane.
| r | Rotation matrix. |
\((R \en)\cdot(\ep-(R v))=(R \en)\cdot \ep-(R \en)\cdot(R v)=(R \en)\cdot \ep-\en\cdot v\) as an orthonormal matrix preserves the dot product ( \((Ra)\cdot (Rb)=(Ra)^t \cdot(Rb)\) and use the property of transpose and orthonormality of R).
| void Plane::Scale | ( | const double & | s | ) |
Scale a plane.
| s | Scaling factor. |
| int Plane::Side | ( | const Vector & | p | ) | const |
Check if a point lies inside, outside or even on the plane.
The epsilon tolerance used for testing if the point is on the plane is \( 10^{-6} \).
| p | Point. |
| double Plane::Signed | ( | const Vector & | p | ) | const |
Compute the signed distance between a point and the plane.
| p | The point. |
Compute the bounding box of the symmetric argument box.
| box | The box. |
Compute the symmetric segment.
| segment | The segment. |
Compute the symmetric sphere.
| sphere | The sphere. |
Compute the point symmetric to the argument point.
The symmetric point is the mirror image of the point with respect to the plane, whose normal should be unit. A point of the plane is its own symmetric.
| p | Point. |
| void Plane::Transform | ( | const Matrix4 & | M | ) |
Transforms a plane given an affine homogeneous transformation matrix. The normal is transformed by the inverse transpose of the linear part of the matrix, which is valid for non uniform scaling and shearing.
| M | Matrix. |
| void Plane::Translate | ( | const double & | t | ) |
Translates a plane in the direction of its normal.
| t | Translation distance. |
| Vector Plane::Vertex | ( | ) | const |
Finds a vertex on the plane.
Compute the point on the plane which is nearest to the origin.
|
friend |
Overloaded.
| s | Stream. |
| plane | The plane. |