VTK-m  2.2
Public Types | Public Member Functions | Public Attributes | List of all members
vtkm::Plane Class Reference

Represent a plane with a base point (origin) and normal vector. More...

#include <Geometry.h>

Public Types

using Vector = vtkm::Vec< CoordType, 3 >
 

Public Member Functions

 Plane ()
 Construct a default plane whose base point is the origin and whose normal is (0,0,1) More...
 
 Plane (const Vector &origin, const Vector &normal, CoordType tol2=static_cast< CoordType >(1e-8f))
 Construct a plane with the given origin and normal. More...
 
bool IsValid () const
 Return true if the plane's normal is well-defined to within the given tolerance. More...
 
CoordType DistanceTo (const Vector &point) const
 Return the signed distance from the plane to the point. More...
 
Vector ClosestPoint (const Vector &point) const
 Return the closest point in the plane to the given point. More...
 
template<bool IsTwoSided>
bool Intersect (const Ray< CoordType, 3, IsTwoSided > &ray, CoordType &parameter, Vector &point, bool &lineInPlane, CoordType tol=CoordType(1e-6f)) const
 Intersect this plane with the ray (or line if the ray is two-sided). More...
 
bool Intersect (const LineSegment< CoordType > &segment, CoordType &parameter, bool &lineInPlane) const
 Intersect this plane with the line segment. More...
 
bool Intersect (const LineSegment< CoordType > &segment, CoordType &parameter, Vector &point, bool &lineInPlane) const
 Intersect this plane with the line segment. More...
 
bool Intersect (const Plane< CoordType > &other, Ray< CoordType, 3, true > &ray, bool &coincident, CoordType tol2=static_cast< CoordType >(1e-6f)) const
 Intersect this plane with another plane. More...
 
 Plane (const Vector &normal={ 0, 0, 1 })
 Construct a plane through the origin with the given normal. More...
 
 Plane (const Vector &origin, const Vector &normal)
 Construct a plane through the given point with the given normal. More...
 
void SetOrigin (const Vector &origin)
 Specify the origin of the plane. More...
 
void SetNormal (const Vector &normal)
 Specify the normal vector to the plane. More...
 
const VectorGetOrigin () const
 Specify the origin of the plane. More...
 
const VectorGetNormal () const
 Specify the normal vector to the plane. More...
 
Scalar Value (const Vector &point) const
 Evaluate the value of the implicit function. More...
 
Vector Gradient (const Vector &) const
 Evaluate the gradient of the implicit function. More...
 

Public Attributes

Vector Origin
 
Vector Normal
 

Detailed Description

Represent a plane with a base point (origin) and normal vector.

Implicit function for a plane.

A plane is defined by a point in the plane and a normal to the plane. The normal does not have to be a unit vector. The implicit function will still evaluate to 0 at the plane, but the values outside the plane (and the gradient) will be scaled by the length of the normal vector.

Member Typedef Documentation

◆ Vector

using vtkm::Plane::Vector = vtkm::Vec<CoordType, 3>

Constructor & Destructor Documentation

◆ Plane() [1/4]

vtkm::Plane::Plane ( )

Construct a default plane whose base point is the origin and whose normal is (0,0,1)

◆ Plane() [2/4]

vtkm::Plane::Plane ( const Vector origin,
const Vector normal,
CoordType  tol2 = static_cast< CoordType >(1e-8f) 
)

Construct a plane with the given origin and normal.

◆ Plane() [3/4]

vtkm::Plane::Plane ( const Vector normal = { 0, 0, 1 })
inlineexplicit

Construct a plane through the origin with the given normal.

◆ Plane() [4/4]

vtkm::Plane::Plane ( const Vector origin,
const Vector normal 
)
inline

Construct a plane through the given point with the given normal.

Member Function Documentation

◆ ClosestPoint()

Vector vtkm::Plane::ClosestPoint ( const Vector point) const

Return the closest point in the plane to the given point.

◆ DistanceTo()

CoordType vtkm::Plane::DistanceTo ( const Vector point) const

Return the signed distance from the plane to the point.

◆ GetNormal()

const Vector& vtkm::Plane::GetNormal ( ) const
inline

Specify the normal vector to the plane.

The magnitude of the plane does not matter (so long as it is more than zero) in terms of the location of the plane where the implicit function equals 0. However, if offsets away from the plane matter then the magnitude determines the scale of the value away from the plane.

◆ GetOrigin()

const Vector& vtkm::Plane::GetOrigin ( ) const
inline

Specify the origin of the plane.

The origin can be any point on the plane.

◆ Gradient()

Vector vtkm::Plane::Gradient ( const Vector ) const
inline

Evaluate the gradient of the implicit function.

The Gradient() method for an implicit function takes a vtkm::Vec3f and returns a vtkm::Vec3f representing the pointing direction from the implicit function's shape. Gradient calculations are more object shape specific. It is advised to look at the individual shape implementations for specific implicit functions.

◆ Intersect() [1/4]

bool vtkm::Plane::Intersect ( const LineSegment< CoordType > &  segment,
CoordType &  parameter,
bool &  lineInPlane 
) const

Intersect this plane with the line segment.

Returns true if there is a non-degenrate intersection (i.e., an isolated point of intersection). Returns false if there is no intersection or if the intersection is degenerate (i.e., the entire line segment lies in the plane). In the latter case, lineInPlane will be true upon exit.

If this method returns true, then parameter will be set to a number in [0,1] indicating where along the line segment the plane hits.

◆ Intersect() [2/4]

bool vtkm::Plane::Intersect ( const LineSegment< CoordType > &  segment,
CoordType &  parameter,
Vector point,
bool &  lineInPlane 
) const

Intersect this plane with the line segment.

Returns true if there is a non-degenrate intersection (i.e., an isolated point of intersection). Returns false if there is no intersection or if the intersection is degenerate (i.e., the entire line segment lines in the plane). In the latter case, lineInPlane will be true upon exit.

If this method returns true, then parameter will be set to a number in [0,1] indicating where along the line segment the plane hits and point will be set to that location.

◆ Intersect() [3/4]

bool vtkm::Plane::Intersect ( const Plane< CoordType > &  other,
Ray< CoordType, 3, true > &  ray,
bool &  coincident,
CoordType  tol2 = static_cast< CoordType >(1e-6f) 
) const

Intersect this plane with another plane.

Returns true if there is a non-degenrate intersection (i.e., a line of intersection). Returns false if there is no intersection or if the intersection is degenerate (i.e., the planes are coincident). In the latter case, coincident will be true upon exit and segment will unmodified.

If this method returns true, then the resulting segment will have its base point on the line of intersection and its second point will be a unit length away in the direction of the cross produce of the input plane normals (this plane crossed with the other).

The tolerance tol is the minimum squared length of the cross-product of the two plane normals. It is also compared to the squared distance of the base point of other away from this plane when considering whether the planes are coincident.

◆ Intersect() [4/4]

template<bool IsTwoSided>
bool vtkm::Plane::Intersect ( const Ray< CoordType, 3, IsTwoSided > &  ray,
CoordType &  parameter,
Vector point,
bool &  lineInPlane,
CoordType  tol = CoordType(1e-6f) 
) const

Intersect this plane with the ray (or line if the ray is two-sided).

Returns true if there is a non-degenrate intersection (i.e., an isolated point of intersection). Returns false if there is no intersection or if the intersection is degenerate (i.e., the entire ray/line lies in the plane). In the latter case, lineInPlane will be true upon exit.

If this method returns true, then parameter will be set to a number indicating where along the ray/line the plane hits and point will be set to that location. If the input is a ray, the parameter will be non-negative.

◆ IsValid()

bool vtkm::Plane::IsValid ( ) const
inline

Return true if the plane's normal is well-defined to within the given tolerance.

◆ SetNormal()

void vtkm::Plane::SetNormal ( const Vector normal)
inline

Specify the normal vector to the plane.

The magnitude of the plane does not matter (so long as it is more than zero) in terms of the location of the plane where the implicit function equals 0. However, if offsets away from the plane matter then the magnitude determines the scale of the value away from the plane.

◆ SetOrigin()

void vtkm::Plane::SetOrigin ( const Vector origin)
inline

Specify the origin of the plane.

The origin can be any point on the plane.

◆ Value()

Scalar vtkm::Plane::Value ( const Vector point) const
inline

Evaluate the value of the implicit function.

The Value() method for an implicit function takes a vtkm::Vec3f and returns a vtkm::FloatDefault representing the orientation of the point with respect to the implicit function's shape. Negative scalar values represent vector points inside of the implicit function's shape. Positive scalar values represent vector points outside the implicit function's shape. Zero values represent vector points that lie on the surface of the implicit function.

Member Data Documentation

◆ Normal

Vector vtkm::Plane::Normal

◆ Origin

Vector vtkm::Plane::Origin

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