FormIt C++ API
v23.0.0 (2023.0.0)
|
The Plane class stores an oriented plane in 3D.
The plane is defined by its (unit) normal vector and parameter d, which is the signed distance of the plane from the origin of the coordinate system.
The following holds for all points on the plane:
normal % point + d = 0
The plane parameters are accessed via public data members, normal and d.
If the plane is invalid (cannot be constructed), the plane normal is set to a null vector.
#include <Plane.h>
Public Member Functions | |
Plane () | |
Plane (const Vector3d &nn, double dd) | |
Plane (const UnitVector3d &nn, double dd) | |
Plane (const Point3d &, const UnitVector3d &) | |
Plane (const Point3d &, const Vector3d &) | |
< More... | |
Plane (const Point3d &, const Point3d &, const Point3d &) | |
Plane (const Point3d &, const Vector3d &, const Vector3d &) | |
Plane (const Point3d plg[], size_t n) | |
Create plane from a polygon of vertices (n >=3). More... | |
Plane (const Point3d plg[], size_t n, const Vector3d &normal) | |
The plane normal is given, just calculate the 'd' parameter from all polygon vertices. More... | |
Plane | operator- () const |
double | dist (const Point3d &p) const |
Point3d | project (const Point3d &) const |
Vector3d | project (const Vector3d &) const |
Line3d | project (const Line3d &) const |
Line3d | operator* (const Plane &) const |
Point3d | operator* (const Line3d &) const |
void | OffsetByDistance (double dDist) |
Offset the Plane by the given distance. More... | |
bool | intersectsInPoint (const Line3d &l, Point3d &pt, double &dParam) const |
Returns true if the plane and line intersect in a single point. More... | |
bool | intersectsInLine (const Plane &pl, Line3d &line) const |
Returns true if the planes intersect in a line. Returns the line if true. More... | |
bool | isValid () const |
bool | isEqual (const Plane &, double dDistTol=WSM_DISTANCE_TOL, double dAngleTol2=WSM_ANGLE_TOL2) const |
isEqual function. More... | |
bool | isEquivalent (const Plane &, double dDistTol=WSM_DISTANCE_TOL, double dAngleTol2=WSM_ANGLE_TOL2) const |
Returns true if geometrically the planes with possibly reversed normals. More... | |
Plane & | negate () |
bool | pointIntersectsNegativeSide (const Point3d &pt, double dTol=WSM_MACHINE_TOL) const |
Returns true if pt lies on the Plane or the negative side of the Plane. More... | |
bool | boxIntersectsNegativeSide (const Interval3d &box, double dTol=WSM_MACHINE_TOL) const |
Returns true if box intersects the negative side of the Plane. More... | |
bool | boxLiesOnNegativeSide (const Interval3d &box, double dTol=WSM_MACHINE_TOL) const |
Returns true if box lies on the negative side of the Plane. More... | |
void | operator*= (const Transf3d &) |
Static Public Member Functions | |
static Plane | fromPoints (const Point3d pts[], size_t pointCount, bool checkPlanarity) |
Create a plane from the given set of coplanar points. More... | |
static Plane | fromPointsUsingThreeNoncollinearPnts (const Point3d pts[], size_t pointCount, bool bCheckPlanarity, int &resultStatus, double dTol=WSM_MACHINE_TOL, bool bTryAgain=false) |
Create a plane from the first three non-collinear points. More... | |
Public Attributes | |
UnitVector3d | normal |
Public data members. More... | |
double | d |
WSM::Plane::Plane | ( | ) |
|
inline |
|
inline |
|
inline |
WSM::Plane::Plane | ( | const Point3d | plg[], |
size_t | n | ||
) |
Create plane from a polygon of vertices (n >=3).
All polygon vertices are used to calculate the plane coefficients to make the formula symmetrical.
The plane normal is given, just calculate the 'd' parameter from all polygon vertices.
bool WSM::Plane::boxIntersectsNegativeSide | ( | const Interval3d & | box, |
double | dTol = WSM_MACHINE_TOL |
||
) | const |
Returns true if box intersects the negative side of the Plane.
bool WSM::Plane::boxLiesOnNegativeSide | ( | const Interval3d & | box, |
double | dTol = WSM_MACHINE_TOL |
||
) | const |
Returns true if box lies on the negative side of the Plane.
|
inline |
|
static |
Create a plane from the given set of coplanar points.
Returns a null plane if the points do not define a plane. Unlike the Plane constructor that takes a closed polygon, the set of points here is just any set of points and the method tries to do some kind of a best fit plane from them
|
static |
Create a plane from the first three non-collinear points.
resultStatus: can be 0, -1, -2. 0: succeeds to find the plane constructed by three non-collinear points;-1: fails to find 3 non-collinear points; -2: fails to satisfy the planarity. dTol is the tolerance use to check if the points are collinear and planar. If bTryAgain is true, on failure tries again using points more optimal then the first three non-collinear points.
Returns true if the planes intersect in a line. Returns the line if true.
Returns true if the plane and line intersect in a single point.
Returns the parameter of intersection if true. Note when the l and the Plane are coincident, the origin point of l is returned. Do we need to add a version that is strict and fails in the case of coincidence?
|
inline |
isEqual function.
Note dAngleTol2 relates to the angle between the normals by 2 - 2 cos(angle) = dAngleTol2. So angle = arccos(1 - dAngleTol2 / 2). The default dAngleTol2 = WSM_ANGLE_TOL2 means equal normals differ by an angle of no more than 5.7295e-9 degrees.
[in] | dDistTol | |
[in] | dAngleTol2 |
|
inline |
Returns true if geometrically the planes with possibly reversed normals.
isEquivalent function.
[in] | dTol | |
[in] | dAngleTol2 | |
[in] | dDistTol |
|
inline |
|
inline |
|
inline |
Offset the Plane by the given distance.
void WSM::Plane::operator*= | ( | const Transf3d & | ) |
|
inline |
bool WSM::Plane::pointIntersectsNegativeSide | ( | const Point3d & | pt, |
double | dTol = WSM_MACHINE_TOL |
||
) | const |
double WSM::Plane::d |
UnitVector3d WSM::Plane::normal |
Public data members.