Easy3D 2.6.1
Loading...
Searching...
No Matches
GenericPlane< FT > Class Template Reference

A 3D Plane of equation a*x + b*y + c*z + d = 0. More...

#include <easy3d/core/plane.h>

Public Types

typedef Vec< 2, FT > Point2
 The type of the 2D point.
 
typedef Vec< 3, FT > Point3
 The type of the 3D point.
 
typedef Vec< 3, FT > Vector3
 The type of the 3D vector.
 
typedef GenericLine< 3, FT > Line3
 The type of the 3D line.
 
typedef GenericPlane< FT > thisclass
 The type of this class.
 

Public Member Functions

 GenericPlane (const Point3 &p1, const Point3 &p2, const Point3 &p3)
 Constructs a plane from three points p1, p2, and p3.
 
 GenericPlane (const Point3 &p, const Vector3 &n)
 Constructs a plane from a point p and the plane normal n.
 
 GenericPlane (FT a, FT b, FT c, FT d)
 Constructs a plane from its equation parameters a, b, c, and d.
 
 GenericPlane ()=default
 Default constructor.
 
FT a () const
 Returns plane equation parameter a.
 
FT b () const
 Returns plane equation parameter b.
 
FT c () const
 Returns plane equation parameter c.
 
FT d () const
 Returns plane equation parameter d.
 
FT & operator[] (size_t idx)
 Returns the idx_th parameter of the plane equation.
 
const FT & operator[] (size_t idx) const
 Returns the idx_th const parameter of the plane equation (const version).
 
Vector3 normal () const
 Returns the normal of the plane.
 
Point3 point () const
 Returns a point lying on this plane.
 
Vector3 base1 () const
 Returns the first ortho-base defined on this plane.
 
Vector3 base2 () const
 Returns the second ortho-base defined on this plane.
 
Point2 to_2d (const Point3 &p) const
 Converts a 3D point into a 2D point relative to the local coordinate system defined by the three orthogonal vectors base1(), base2(), and normal().
 
Point3 to_3d (const Point2 &p) const
 Converts a 2D point in the local coordinate system defined by the three orthogonal vectors base1(), base2(), and normal() into the 3D space.
 
Point3 projection (const Point3 &p) const
 The projection of a point p on this plane.
 
FT value (const Point3 &p) const
 Evaluates the plane (i.e., computes the value of a * x + b * y + c * z + d) for the given point p.
 
FT squared_distance (const Point3 &p) const
 Computes the squared distance of a point p to this plane.
 
bool intersect (const Line3 &line, Point3 &p) const
 Tests if a line intersects with this plane (both line and the plane are unlimited).
 
bool intersect (const Line3 &line) const
 Tests if a line intersects with this plane (both line and the plane are unlimited).
 
bool intersect (const Point3 &s, const Point3 &t, Point3 &p) const
 Tests if a line segment (given by its two end points s and t) intersects with this plane.
 
bool intersect (const Point3 &s, const Point3 &t) const
 Tests if a line segment (given by its two end points s and t) intersects with this plane.
 
bool intersect (const thisclass &another, Line3 &line) const
 Tests if this plane intersects with another plane.
 
bool intersect (const thisclass &another) const
 Tests if this plane intersects with another plane.
 
int orient (const Point3 &p) const
 Determines the relative orientation of a point with respect to this plane.
 
const FT * data () const
 Returns the constant memory address of the coefficients.
 
FT * data ()
 Returns the memory address of the coefficients.
 
 operator const FT * () const
 Conversion operator returning the constant memory address of the coefficients. This is very convenient to pass a plane as a parameter to functions.
 
 operator FT * ()
 Conversion operator returning the memory address of the coefficients. This is very convenient to pass a plane as a parameter to functions.
 

Detailed Description

template<typename FT>
class easy3d::GenericPlane< FT >

A 3D Plane of equation a*x + b*y + c*z + d = 0.

Template Parameters
FTThe scalar type for plane coefficients.

Constructor & Destructor Documentation

◆ GenericPlane() [1/3]

template<typename FT>
GenericPlane ( const Point3 & p1,
const Point3 & p2,
const Point3 & p3 )

Constructs a plane from three points p1, p2, and p3.

Parameters
p1The first point.
p2The second point.
p3The third point.

◆ GenericPlane() [2/3]

template<typename FT>
GenericPlane ( const Point3 & p,
const Vector3 & n )

Constructs a plane from a point p and the plane normal n.

Parameters
pThe point on the plane.
nThe normal vector of the plane.

◆ GenericPlane() [3/3]

template<typename FT>
GenericPlane ( FT a,
FT b,
FT c,
FT d )
inline

Constructs a plane from its equation parameters a, b, c, and d.

Parameters
aThe coefficient for x.
bThe coefficient for y.
cThe coefficient for z.
dThe constant term.

Member Function Documentation

◆ a()

template<typename FT>
FT a ( ) const
inline

Returns plane equation parameter a.

Returns
The coefficient a.

◆ b()

template<typename FT>
FT b ( ) const
inline

Returns plane equation parameter b.

Returns
The coefficient b.

◆ base1()

template<typename FT>
GenericPlane< FT >::Vector3 base1 ( ) const

Returns the first ortho-base defined on this plane.

Returns
The first ortho-base vector.

◆ base2()

template<typename FT>
GenericPlane< FT >::Vector3 base2 ( ) const

Returns the second ortho-base defined on this plane.

Returns
The second ortho-base vector.

◆ c()

template<typename FT>
FT c ( ) const
inline

Returns plane equation parameter c.

Returns
The coefficient c.

◆ d()

template<typename FT>
FT d ( ) const
inline

Returns plane equation parameter d.

Returns
The coefficient d.

◆ data() [1/2]

template<typename FT>
FT * data ( )
inline

Returns the memory address of the coefficients.

Returns
The memory address of the coefficients.

◆ data() [2/2]

template<typename FT>
const FT * data ( ) const
inline

Returns the constant memory address of the coefficients.

Returns
The constant memory address of the coefficients.

◆ intersect() [1/6]

template<typename FT>
bool intersect ( const Line3 & line) const

Tests if a line intersects with this plane (both line and the plane are unlimited).

Parameters
lineThe line to test.
Returns
true if they intersect, false otherwise (the line is parallel to this plane).

◆ intersect() [2/6]

template<typename FT>
bool intersect ( const Line3 & line,
Point3 & p ) const

Tests if a line intersects with this plane (both line and the plane are unlimited).

Parameters
lineThe line to test.
pThe intersection point if they intersect.
Returns
true if they intersect, false otherwise (the line is parallel to this plane).

◆ intersect() [3/6]

template<typename FT>
bool intersect ( const Point3 & s,
const Point3 & t ) const

Tests if a line segment (given by its two end points s and t) intersects with this plane.

Parameters
sThe start point of the line segment.
tThe end point of the line segment.
Returns
true if they intersect, false otherwise (the two end points of the line segment lie on the same side of the plane).

◆ intersect() [4/6]

template<typename FT>
bool intersect ( const Point3 & s,
const Point3 & t,
Point3 & p ) const

Tests if a line segment (given by its two end points s and t) intersects with this plane.

Parameters
sThe start point of the line segment.
tThe end point of the line segment.
pThe intersection point if they intersect.
Returns
true if they intersect, false otherwise (the two end points of the line segment lie on the same side of the plane).

◆ intersect() [5/6]

template<typename FT>
bool intersect ( const thisclass & another) const

Tests if this plane intersects with another plane.

Parameters
anotherThe other plane to test.
Returns
true if they intersect, false otherwise (the two planes are parallel).

◆ intersect() [6/6]

template<typename FT>
bool intersect ( const thisclass & another,
Line3 & line ) const

Tests if this plane intersects with another plane.

Parameters
anotherThe other plane to test.
lineThe intersecting line if they intersect.
Returns
true if they intersect, false otherwise (the two planes are parallel).

◆ normal()

template<typename FT>
GenericPlane< FT >::Vector3 normal ( ) const

Returns the normal of the plane.

Returns
The normal vector of the plane.

◆ operator const FT *()

template<typename FT>
operator const FT * ( ) const
inline

Conversion operator returning the constant memory address of the coefficients. This is very convenient to pass a plane as a parameter to functions.

Returns
The constant memory address of the coefficients.

◆ operator FT *()

template<typename FT>
operator FT * ( )
inline

Conversion operator returning the memory address of the coefficients. This is very convenient to pass a plane as a parameter to functions.

Returns
The memory address of the coefficients.

◆ operator[]() [1/2]

template<typename FT>
FT & operator[] ( size_t idx)
inline

Returns the idx_th parameter of the plane equation.

Parameters
idxThe index of the parameter.
Returns
The idx_th parameter.

◆ operator[]() [2/2]

template<typename FT>
const FT & operator[] ( size_t idx) const
inline

Returns the idx_th const parameter of the plane equation (const version).

Parameters
idxThe index of the parameter.
Returns
The idx_th const parameter.

◆ orient()

template<typename FT>
int orient ( const Point3 & p) const

Determines the relative orientation of a point with respect to this plane.

Parameters
pThe point to test.
Returns
1 if the point is on the positive side, -1 if on the negative side, 0 if on the plane.

◆ point()

template<typename FT>
GenericPlane< FT >::Point3 point ( ) const

Returns a point lying on this plane.

Note
It is a fixed point (anytime you call this function it returns the same point).
Returns
A point on the plane.

◆ projection()

template<typename FT>
GenericPlane< FT >::Point3 projection ( const Point3 & p) const

The projection of a point p on this plane.

Parameters
pThe point to project.
Returns
The projected point on the plane.

◆ squared_distance()

template<typename FT>
FT squared_distance ( const Point3 & p) const

Computes the squared distance of a point p to this plane.

Parameters
pThe point to compute the distance to.
Returns
The squared distance to the plane.

◆ to_2d()

template<typename FT>
GenericPlane< FT >::Point2 to_2d ( const Point3 & p) const

Converts a 3D point into a 2D point relative to the local coordinate system defined by the three orthogonal vectors base1(), base2(), and normal().

Parameters
pThe 3D point to convert.
Returns
The corresponding 2D point.
Note
After 3D->2D and then 2D->3D conversion, the resulted 3D point remains unchanged ONLY IF the input point lies on the plane. In case the original 3D point does not lie on the plane, the resulted 3D point will have coordinates equal to the projection of the input point onto the plane.

◆ to_3d()

template<typename FT>
GenericPlane< FT >::Point3 to_3d ( const Point2 & p) const

Converts a 2D point in the local coordinate system defined by the three orthogonal vectors base1(), base2(), and normal() into the 3D space.

Parameters
pThe 2D point to convert.
Returns
The corresponding 3D point.
Note
After 3D->2D and then 2D->3D conversion, the resulted 3D point remains unchanged ONLY IF the input point lies on the plane. In case the original 3D point does not lie on the plane, the resulted 3D point will have coordinates equal to the projection of the input point onto the plane.

◆ value()

template<typename FT>
FT value ( const Point3 & p) const
inline

Evaluates the plane (i.e., computes the value of a * x + b * y + c * z + d) for the given point p.

Parameters
pThe point to evaluate.
Returns
The evaluated value.

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