![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/Geometry/Plane.h>
Class representing an oriented plane in 3D space defined by a base point and a normal direction. More...
Class representing an oriented plane in 3D space defined by a base point and a normal direction.
Unless stated otherwise, all operations that involve comparisons use the same tolerance epsilon as vec3::isApprox (which is 1e-12).
Public Member Functions | |
Plane (const vec3 &point, const vec3 &normal) | |
Construct plane from point and normal, the latter will be normalized. | |
Plane (const Rectangle &rect) | |
Construct plane by extending a rectangle. User is responsible for the rectangle being valid. | |
vec4 | hesseNormalForm () const |
Returns [normal, d] with d >= 0 such that for any point p its distance to the plane is given by abs(p.dot(normal) - d) . | |
vec4 | computerVisionNormalForm () const |
Returns cvnf = [normal, d] such that for any point p its distance to the plane is given by abs(p.dot(normal) + d) , in terser notation: abs(p.homogeneous().dot(cvnf)) . | |
const vec3 & | point () const |
const vec3 & | normal () const |
bool | isApprox (const Plane &other) |
Comparison using the same epsilon as Eigen::isApprox. | |
bool | isEquivalent (const Plane &other, bool considerOrientation=false) |
Returns if both Plane objects describe the same geometrical objects. | |
vec3 | closestPoint (const vec3 &p) const |
Returns the point on the plane closest to p. | |
double | distanceToPoint (const vec3 &p) const |
Returns the L2 distance between p and the closest point on the plane. | |
double | signedDistanceToPoint (const vec3 &p) const |
Returns the dot product of the vector from the plane towards p and the plane normal. | |
bool | includesPoint (const vec3 &p) const |
Returns if p sits on the plane. | |
Static Public Member Functions | |
static Plane | fromComputerVisionNormalForm (const vec4 &cvnf) |
Construct plane from normal form, see computerVisionNormalForm() for details. | |
bool | operator== (const Plane &) const |
Exact comparisons of Plane instances based on the point() and normal(). | |
bool | operator!= (const Plane &) const |
Plane | ( | const vec3 & | point, |
const vec3 & | normal ) |
Construct plane from point and normal, the latter will be normalized.
Passing something that cannot be normalized will invalidate the plane (does not intersect, distance to anything is NAN).
vec4 hesseNormalForm | ( | ) | const |
Returns [normal, d]
with d >= 0
such that for any point p
its distance to the plane is given by abs(p.dot(normal) - d)
.
d
component of the Hesse Normal Form is always positive. This means that the sign of the normal
component may be flipped wrt. the plane's normal effectively flipping the orientation of the plane. Use computerVisionNormalForm() as alternative representation where the normal
component always equals normal(). vec4 computerVisionNormalForm | ( | ) | const |
Returns cvnf = [normal, d]
such that for any point p
its distance to the plane is given by abs(p.dot(normal) + d)
, in terser notation: abs(p.homogeneous().dot(cvnf))
.
normal
component always has the same sign as normal() and the d
component may be negative. Therefore, this form maintains the orientation of the plane enabling you to easily determine if a point is on its front or back side. Also, please note the slight difference in the distance computation formula above: this form requires adding the d
component while the hesseNormalForm() requires subtracting it. bool operator== | ( | const Plane & | ) | const |
Exact comparisons of Plane instances based on the point() and normal().
If you instead want to check if the represented geometric structures are the same, use isEquivalent().
bool isEquivalent | ( | const Plane & | other, |
bool | considerOrientation = false ) |
Returns if both Plane objects describe the same geometrical objects.
Note that unlike all other comparisons provided here this allows anti-parallel normals and using different points to define the same position.