FormIt C++ API  v23.0.0 (2023.0.0)
WSM::Plane Class Reference

Description

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...
 
Planenegate ()
 
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
 

Constructor & Destructor Documentation

WSM::Plane::Plane ( )
WSM::Plane::Plane ( const Vector3d nn,
double  dd 
)
inline
WSM::Plane::Plane ( const UnitVector3d nn,
double  dd 
)
inline
WSM::Plane::Plane ( const Point3d p,
const UnitVector3d norm 
)
inline
WSM::Plane::Plane ( const Point3d p,
const Vector3d norm 
)
inline

<

WSM::Plane::Plane ( const Point3d ,
const Point3d ,
const Point3d  
)
WSM::Plane::Plane ( const Point3d ,
const Vector3d ,
const Vector3d  
)
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.

WSM::Plane::Plane ( const Point3d  plg[],
size_t  n,
const Vector3d normal 
)

The plane normal is given, just calculate the 'd' parameter from all polygon vertices.

Member Function Documentation

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.

double WSM::Plane::dist ( const Point3d p) const
inline
static Plane WSM::Plane::fromPoints ( const Point3d  pts[],
size_t  pointCount,
bool  checkPlanarity 
)
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 Plane WSM::Plane::fromPointsUsingThreeNoncollinearPnts ( const Point3d  pts[],
size_t  pointCount,
bool  bCheckPlanarity,
int &  resultStatus,
double  dTol = WSM_MACHINE_TOL,
bool  bTryAgain = false 
)
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.

bool WSM::Plane::intersectsInLine ( const Plane pl,
Line3d line 
) const

Returns true if the planes intersect in a line. Returns the line if true.

bool WSM::Plane::intersectsInPoint ( const Line3d l,
Point3d pt,
double &  dParam 
) const

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?

bool WSM::Plane::isEqual ( const Plane pla,
double  dDistTol = WSM_DISTANCE_TOL,
double  dAngleTol2 = WSM_ANGLE_TOL2 
) const
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.

Parameters
[in]dDistTol
[in]dAngleTol2
bool WSM::Plane::isEquivalent ( const Plane pla,
double  dDistTol = WSM_DISTANCE_TOL,
double  dAngleTol2 = WSM_ANGLE_TOL2 
) const
inline

Returns true if geometrically the planes with possibly reversed normals.

isEquivalent function.

Parameters
[in]dTol
[in]dAngleTol2
[in]dDistTol
bool WSM::Plane::isValid ( ) const
inline
Plane& WSM::Plane::negate ( )
inline
void WSM::Plane::OffsetByDistance ( double  dDist)
inline

Offset the Plane by the given distance.

Line3d WSM::Plane::operator* ( const Plane ) const
Point3d WSM::Plane::operator* ( const Line3d ) const
void WSM::Plane::operator*= ( const Transf3d )
Plane WSM::Plane::operator- ( ) const
inline
bool WSM::Plane::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.

Point3d WSM::Plane::project ( const Point3d ) const
Vector3d WSM::Plane::project ( const Vector3d ) const
Line3d WSM::Plane::project ( const Line3d ) const

Member Data Documentation

double WSM::Plane::d
UnitVector3d WSM::Plane::normal

Public data members.


The documentation for this class was generated from the following file: