Plane
Class representing a two dimensional surface that extends infinitely in 3D space. A plane is represented in Hessian normal form by a unit length normal vector and a constant. The plane equation is: normal.x * x + normal.y * y + normal.z * z + constant = 0
Methods
Plane(const Vector3& normal, f32 constant)
Constructor to create new plane
| normal | normal of the plane | Vector3(1,0,0) |
| constant | distance from the origin to the plane | 0.0f |
Plane& set(const Vector3& normal, f32 constant)
Sets the plane components by copying the given values
| normal | The normal | |
| constant | The constant |
Plane& setComponents(f32 x, f32 y, f32 z, f32 w)
Sets the plane components by defining x, y, z as the plane normal and w as the constant
| x | The value for the normal's x component | |
| y | The value for the normal's y component | |
| z | The value for the normal's z component | |
| w | The constant value |
Plane& setFromNormalAndCoplanarPoint(const Vector3& normal, const Vector3& point)
Sets the plane from the given normal and coplanar point
| normal | The normal | |
| point | A coplanar point |
Plane& setFromCoplanarPoints(const Vector3& a, const Vector3& b, const Vector3& c)
Sets the plane from three coplanar points
| a | The first coplanar point | |
| b | The second coplanar point | |
| c | The third coplanar point |
Plane clone() const
Returns a new plane with copied values from this instance
Plane& copy(const Plane& plane)
Copies the values of the given plane to this instance
| plane | Plane to copy from |
Plane& normalize()
Normalizes the plane normal and adjusts the constant accordingly
Plane& negate()
Negates both the plane normal and the constant
f32 distanceToPoint(const Vector3& point) const
Returns the signed distance from the given point to this plane
| point | The point to compute the distance for |
f32 distanceToSphere(const Sphere& sphere) const
Returns the signed distance from the given sphere to this plane
| sphere | The sphere to compute the distance for |
Vector3& coplanarPoint(Vector3& target) const
Returns a coplanar vector to the plane, by calculating the projection of the normal at the origin onto the plane
| target | The target vector that is used to store the method's result |
Vector3* intersectLine(const Vector3& lineStart, const Vector3& lineEnd, Vector3& target) const
Returns the intersection point of the passed line and the plane
| lineStart | Start point of the line | |
| lineEnd | End point of the line | |
| target | The target vector that is used to store the method's result |
bool intersectsLine(const Vector3& lineStart, const Vector3& lineEnd) const
Returns true if the given line segment intersects with (passes through) the plane
| lineStart | Start point of the line | |
| lineEnd | End point of the line |
bool intersectsBox(const Box3& box) const
Returns true if the given bounding box intersects with the plane
| box | The bounding box to test |
bool intersectsSphere(const Sphere& sphere) const
Returns true if the given bounding sphere intersects with the plane
| sphere | The bounding sphere to test |
Vector3& projectPoint(const Vector3& point, Vector3& target) const
Projects a the given point onto the plane
| point | The point to project | |
| target | The target vector that is used to store the method's result |
Plane& applyMatrix4(const Matrix4& matrix, const Matrix3* optionalNormalMatrix)
Apply a 4x4 matrix to the plane
| matrix | The transformation matrix | |
| optionalNormalMatrix | A pre-computed normal matrix (can be nullptr) |
Plane& translate(const Vector3& offset)
Translates the plane by the distance defined by the given offset vector
| offset | The offset vector |
bool equals(const Plane& plane) const
Returns true if this plane is equal with the given one
| plane | Plane to compare with this one |
bool operator==(const Plane& plane) const
Checks if this plane equals another
| plane | Plane to compare with |
bool operator!=(const Plane& plane) const
Checks if this plane does not equal another
| plane | Plane to compare with |
Properties
| constant | f32 | The signed distance from the origin to the plane |
| enabled | bool | Active/inactive |
| id | u32 | Unique identifier |
| isPlane | bool | Read-only tag |
| name | string | Optional display name |
| normal | Vector3 | Unit length vector defining the normal of the plane |
| uuid | string | UUID string |
| version | u32 | Bumps on change |