Core 1.0
|
A plane defined by its analytic equation. More...
#include <plane.h>
Public Member Functions | |
Plane () | |
Empty. | |
Plane (const double &, const double &, const double &, const double &) | |
Creates a plane given its analytic equation. More... | |
Plane (const Vector &, const double &) | |
Creates a plane given normal and distance. More... | |
Plane (const Vector &, const Vector &) | |
Creates a plane given normal and vertex. More... | |
Plane (const Vector &) | |
Creates a plane given normal passing through the origin. More... | |
~Plane () | |
Empty. | |
bool | Intersect (const Ray &, double &) const |
Compute the intersection between a plane and a ray. More... | |
bool | Inside (const Vector &) const |
Check if a point is inside or outside the plane. More... | |
int | Side (const Vector &) const |
Check if a point lies inside, outside or even on the plane. More... | |
Vector | Normal () const |
Returns the normal to the plane. | |
Vector | Vertex () const |
Finds a vertex on the plane. More... | |
double | R (const Vector &) const |
Compute the squared distance to the half space delimited by the plane. More... | |
double | Signed (const Vector &) const |
Compute the signed distance between a point and the plane. More... | |
double | Eval (const Vector &) const |
Evaluates the equation of the plane. More... | |
void | Transform (const Matrix4 &) |
Transforms a plane given a homogeneous transformation matrix. More... | |
void | Translate (const double &) |
Translates a plane in the direction of its normal. More... | |
void | Rotate (const Matrix &) |
Rotate a plane. More... | |
Vector | Symmetry (const Vector &) const |
Compute the point symmetric to the argument point. More... | |
Box | Symmetric (const Box &) const |
Compute the boundix box of the symmetric argument box. More... | |
Segment | Symmetric (const Segment &) const |
Compute the symmetric segment. More... | |
Sphere | Symmetric (const Sphere &) const |
Compute the symmetric sphere. More... | |
Vector | Reflect (const Vector &) const |
Compute the reflected direction. More... | |
bool | Refract (const Vector &, const double &, Vector &) const |
Compute the refracted direction. More... | |
Vector | Intersect (const Line &) const |
Compute the intersection between a plane and a line. More... | |
bool | Intersect (const Segment &, double &) const |
Compute the intersection between a plane and a segment. More... | |
Quadric | Equation (const Ray &) const |
Compute the quadric equation of the Euclidean distance to the plane. More... | |
Frame | GetFrame () const |
Return a Frame attached to the plane. More... | |
Axis | Intersect (const Plane &) const |
Compute the intesection between two planes. More... | |
Static Public Member Functions | |
static void | Cast (const Vector &, double &, double &) |
Compute the inverse mapping coordinates of a point. More... | |
static Vector | Intersection (const Plane &, const Plane &, const Plane &) |
Compute the intersection between three planes. More... | |
static QVector< Vector > | ConvexPoints (const QVector< Plane > &) |
Compute the intersection of a set of half spaces. More... | |
static Vector | Reflect (const Vector &, const Vector &) |
Given an input (normalized) normal, compute a reflected direction. The code is the same as: More... | |
static bool | Refract (const Vector &, const Vector &, const double &, Vector &) |
Compute the refracted direction. More... | |
Static Public Attributes | |
static const double | epsilon = 1e-06 |
Small value for checking intersection with a ray. | |
static const Plane | Horizontal |
Reference horizontal plane. | |
Protected Attributes | |
Vector | n = Vector::Z |
Plane normal. | |
double | c = 0.0 |
Plane coefficient. | |
Friends | |
std::ostream & | operator<< (std::ostream &, const Plane &) |
Overloaded. More... | |
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 its analytic equation.
a,b,c | Coefficients of the plane normal, the plane normal should be unit.. |
d | Plane constant. |
|
inlineexplicit |
Creates a plane given normal and distance.
n | Plane 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 intesection between two planes.
Planes should not be coplanar.
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. |
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 boundix 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.
p | Point. |
void Plane::Transform | ( | const Matrix4 & | M | ) |
Transforms a plane given a homogeneous transformation matrix.
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.
Basically computes the point on the plane which is nearest to the origin.
|
friend |
Overloaded.
s | Stream. |
plane | The plane. |