CUGL 2.3
Cornell University Game Library
|
#include <CUPlane.h>
Public Types | |
enum class | Side { INCIDENT , BACK , FRONT } |
Public Member Functions | |
Plane () | |
Plane (const Vec3 normal, float dist=0) | |
Plane (const Vec3 normal, const Vec3 point) | |
Plane (const Vec3 point1, const Vec3 point2, const Vec3 point3) | |
Plane (float a, float b, float c, float d) | |
Plane (const Plane &plane) | |
~Plane () | |
Plane & | operator= (const Plane &plane) |
Plane & | operator= (const Vec3 normal) |
Plane & | set (const Vec3 normal, float dist=0) |
Plane & | set (const Vec3 normal, const Vec3 point) |
Plane & | set (const Vec3 point1, const Vec3 point2, const Vec3 point3) |
Plane & | set (float a, float b, float c, float d) |
Plane & | set (const Plane &plane) |
Plane & | multiply (const Mat4 &mat) |
Plane & | operator*= (const Mat4 &mat) |
const Plane | operator* (const Mat4 &mat) const |
float | distance (const Vec3 point) const |
float | getIntersection (const Ray &ray) const |
bool | contains (const Vec3 point, float variance=CU_MATH_EPSILON) const |
Side | sideOf (const Vec3 point) const |
Side | sideOf (float x, float y, float z) const |
bool | isFrontFacing (const Vec3 direction) const |
bool | operator== (const Plane &p) const |
bool | operator!= (const Plane &p) const |
bool | equals (const Plane &p, float variance=CU_MATH_EPSILON) const |
std::string | toString (bool verbose=false) const |
operator std::string () const | |
Static Public Member Functions | |
static Plane * | multiply (const Plane &plane, const Mat4 &mat, Plane *dst) |
static float | intersection (const Plane &plane, const Ray &ray) |
Public Attributes | |
Vec3 | normal |
float | offset |
Static Public Attributes | |
static const Plane | XY |
static const Plane | XZ |
static const Plane | YZ |
This class ia a plane defined via a normal and the distance from the origin.
The normal must be a unit vector. However, we allow direct access to the normal and do not check this invariant.
|
strong |
|
inline |
Creates the XY plane.
|
inline |
Creates a new plane with the given normal and distance to the origin.
normal | The plane normal |
dist | The distance to the origin |
Creates a new plane based on the normal and a point on the plane.
normal | The normal |
point | The point on the plane |
Creates a new plane containing the three given points.
The normal is calculated via a cross product between (point1-point2)x(point2-point3)
point1 | The first point |
point2 | The second point |
point3 | The third point |
|
inline |
Creates a new plane from the given equation coefficients.
The equation of the plane is ax + by + cz = d.
a | The x coefficient |
b | The y coefficient |
c | The z coefficient |
d | The constant factor |
|
inline |
Creates a copy of the given plane.
plane | The plane to copy, |
|
inline |
Destroys this plane, releasing all resources
|
inline |
Returns true if this plane contains the given point within tolerance.
The tolerance bounds the point distance.
point | The point to check |
variance | The comparison tolerance. |
|
inline |
Return the signed distance between the plane and the given point.
The distance is signed, so that a point on the same side as the normal will have positive distance, while a point on the back side will have negative distance.
|
inline |
Returns true if the planes are within tolerance of each other.
The tolerance bounds the normal and distance separately.
p | The plane to compare against. |
variance | The comparison tolerance. |
|
inline |
Returns the intersection parameter of the ray with this plane.
If the value is negative, the intersection is in the reverse direction of the ray.
ray | The ray to check |
Computes the intersection paramter the ray with the plane.
If the value is negative, the intersection is in the reverse direction of the ray.
plane | The plane to check |
ray | The ray to check |
|
inline |
Returns whether the plane is facing the direction vector.
In this method, you should think of the direction vector as the direction a camera looks in. This method will return true if the front side of the plane determined by its normal faces the camera.
direction | The direction |
Multiplies this plane by the given matrix.
The multiplication transforms the plane. That is, if point p is on the original plane, p*M is on the newly created plane. To transform a plane by a matrix, we mutliply the vector (a,b,c,d) by the inverse of mat, where ax + by + cz = d is the equation of the plane.
mat | The transform matrix |
Multiplies the plane by the given matrix and assigns it to dst.
The multiplication transforms the plane. That is, if point p is on the original plane, p*M is on the newly created plane. To transform a plane by a matrix, we mutliply the vector (a,b,c,d) by the inverse of mat, where ax + by + cz = d is the equation of the plane.
plane | The plane to transform |
mat | The transform matrix |
dst | A plane to store the result in |
|
inline |
Cast from Ray to a string.
|
inline |
Returns true if this plane is not equal to the given plane.
Comparison is exact, which may be unreliable given that the attributes are floats.
p | The plane to compare against. |
Return a copy of this plane transformed by the given matrix.
The multiplication transforms the plane. That is, if point p is on the original plane, p*M is on the newly created plane. To transform a plane by a matrix, we mutliply the vector (a,b,c,d) by the inverse of mat, where ax + by + cz = d is the equation of the plane.
mat | The transform matrix |
Multiplies this plane by the given matrix.
The multiplication transforms the plane. That is, if point p is on the original plane, p*M is on the newly created plane. To transform a plane by a matrix, we mutliply the vector (a,b,c,d) by the inverse of mat, where ax + by + cz = d is the equation of the plane.
mat | The transform matrix |
Sets this plane to be a copy of the given plane.
plane | The plane to copy, |
Sets this plane to have the given normal.
After assignment, this plane will intersect the origin.
normal | The plane normal |
|
inline |
Returns true if this plane is equal to the given plane.
Comparison is exact, which may be unreliable given that the attributes are floats.
p | The plane to compare against. |
Sets this plane to be a copy of the given plane.
plane | The plane to copy, |
Sets this plane to have the given normal and contain the given point.
normal | The normal |
point | The point on the plane |
Sets this plane to have the given normal and distance to the origin.
normal | The plane normal |
dist | The distance to the origin |
Creates a new plane to one containing the three given points.
The normal is calculated via a cross product between (point1-point2)x(point2-point3)
point1 | The first point |
point2 | The second point |
point3 | The third point |
Plane & cugl::Plane::set | ( | float | a, |
float | b, | ||
float | c, | ||
float | d | ||
) |
Sets this plane to have the given equation coefficients.
The equation of the plane is ax + by + cz = d.
a | The x coefficient |
b | The y coefficient |
c | The z coefficient |
d | The constant factor |
Returns which side the given point lies relative to normal.
Side::FRONT refers to the side the plane normal points to.
point | The point to check |
|
inline |
Returns which side the given point lies relative to normal.
Side::FRONT refers to the side the plane normal points to.
x | The x-coordinate of the point |
y | The x-coordinate of the point |
z | The x-coordinate of the point |
std::string cugl::Plane::toString | ( | bool | verbose = false | ) | const |
Returns a string representation of this plane for debugging purposes.
The plane will be represented by its equation ax+by+cz = d.
If verbose is true, the string will include class information. This allows us to unambiguously identify the class.
verbose | Whether to include class information |
Vec3 cugl::Plane::normal |
The plane normal (should be a unit vector)
float cugl::Plane::offset |
The distance of the plane from the origin
|
static |
The xy plane (normal is z-axis)
|
static |
The xz plane (normal is y-axis)
|
static |
The yz plane (normal is x-axis)