Core 1.0
Slab Class Reference

A simple slab class. More...

#include <slab.h>

Inheritance diagram for Slab:
Plane

Public Member Functions

 Slab (const Plane &, const double &=0.0)
 Create a slab given a normal direction and two points.
 Slab (const QVector< Vector > &, const Vector &)
 Create a slab given a normal direction and a set of points.
 Slab ()
 Empty.
 ~Slab ()
 Empty.
Vector Normal () const
 Return the normal direction of the slab.
double R (const Vector &) const
 Compute the squared distance to the slab.
double Signed (const Vector &) const
 Compute the signed distance to the slab.
Vector Normal (const Vector &) const
 Compute the distance vector between a slab and a given point.
void Scale (const double &)
 Scale a slab.
bool Intersect (const Ray &, double &, double &) const
 Compute the intersection between a slab and a ray.
bool Inside (const Vector &) const
 Check if a point is inside the slab.
void Rotate (const Matrix &)
 Rotate a plane.
void Translate (const double &)
 Translates a plane in the direction of its normal.

Static Public Attributes

static double epsilon = 1.0e-5
 Internal epsilon constant.

Protected Attributes

double e = 0.0
 Thickness.
Protected Attributes inherited from Plane
Vector n = Vector::Z
 Plane normal.
double cqc = 0.0
 Plane coefficient.

Additional Inherited Members

Protected Member Functions inherited from Plane
 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 a homogeneous transformation matrix.
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 intesection between two planes.
Static Protected Member Functions inherited from Plane
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< VectorConvexPoints (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 Protected Attributes inherited from Plane
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.

Detailed Description

A simple slab class.

The class stores the normal and the constant coefficient of the plane equations.

This class implements some optimized functions, such as the intersection with a ray.

Constructor & Destructor Documentation

◆ Slab() [1/2]

Slab::Slab ( const Plane & plane,
const double & t = 0.0 )
explicit

Create a slab given a normal direction and two points.

Parameters
planePlane.
tThickness.

◆ Slab() [2/2]

Slab::Slab ( const QVector< Vector > & p,
const Vector & n )
explicit

Create a slab given a normal direction and a set of points.

Parameters
pSet of points.
nPlane normal.

Member Function Documentation

◆ Inside()

bool Slab::Inside ( const Vector & p) const

Check if a point is inside the slab.

Parameters
pPoint.

◆ Intersect()

bool Slab::Intersect ( const Ray & ray,
double & tmin,
double & tmax ) const

Compute the intersection between a slab and a ray.

Sorted intersection depths are returned if intersection occurs.

Parameters
rayThe ray.
tmin,tmaxIntersection depths.

◆ Normal()

Vector Slab::Normal ( const Vector & p) const

Compute the distance vector between a slab and a given point.

Parameters
pPoint.

◆ R()

double Slab::R ( const Vector & p) const

Compute the squared distance to the slab.

Parameters
pPoint.

◆ Rotate()

void Plane::Rotate ( const Matrix & r)

Rotate a plane.

Parameters
rRotation 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).

◆ Scale()

void Slab::Scale ( const double & s)

Scale a slab.

Parameters
sScaling factor.

◆ Signed()

double Slab::Signed ( const Vector & p) const

Compute the signed distance to the slab.

Parameters
pPoint.

◆ Translate()

void Plane::Translate ( const double & t)

Translates a plane in the direction of its normal.

Parameters
tTranslation distance.