RobWorkProject  24.8.23-
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
Plane Class Reference

plane primitive represented in Hessian normal-form: a*nx+b*ny+c*nz+d=0 More...

#include <Plane.hpp>

Inherits Primitive.

Public Types

typedef rw::core::Ptr< PlanePtr
 Smart pointer to Plane.
 
typedef double value_type
 The value type for a plane (double precision).
 
- Public Types inherited from Primitive
typedef rw::core::Ptr< PrimitivePtr
 Smart pointer to this type of class.
 
- Public Types inherited from GeometryData
enum  GeometryType {
  PointCloud , LineMesh , PlainTriMesh , IdxTriMesh ,
  SpherePrim , BoxPrim , OBBPrim , AABBPrim ,
  LinePrim , PointPrim , PyramidPrim , ConePrim ,
  TrianglePrim , CylinderPrim , TubePrim , PlanePrim ,
  RayPrim , Implicit , Quadratic , UserType
}
 geometry data types
 
typedef rw::core::Ptr< GeometryDataPtr
 smart pointer type to this class
 
typedef rw::core::Ptr< const GeometryDataCPtr
 const smart pointer type to this class
 

Public Member Functions

 Plane ()
 Constructor. More...
 
 Plane (const rw::math::Q &q)
 constructor More...
 
 Plane (const rw::math::Vector3D< double > &n, const double d)
 constructor More...
 
 Plane (const rw::math::Vector3D< double > &p1, const rw::math::Vector3D< double > &p2, const rw::math::Vector3D< double > &p3)
 constructor - calculates the plane from 3 vertices More...
 
virtual ~Plane ()
 destructor
 
rw::math::Vector3D< double > & normal ()
 get plane normal
 
const rw::math::Vector3D< double > & normal () const
 get plane normal
 
double & d ()
 get distance to {0,0,0} from plane along normal.
 
double d () const
 get distance to {0,0,0} from plane along normal.
 
double distance (const rw::math::Vector3D< double > &point) const
 Calculates the shortest distance from point to plane. More...
 
double distance (const Plane &plane) const
 Default metric for computing the difference between 2 planes. More...
 
double refit (const std::vector< rw::math::Vector3D< double >> &data)
 Fit this plane to a set of points. More...
 
rw::math::Vector3D< double > intersection (const rw::math::Vector3D< double > &p1, const rw::math::Vector3D< double > &p2) const
 Calculates the intersection between the line and plane. More...
 
TriMesh::Ptr createMesh (int resolution) const
 make a trimesh from this primitive. Use granularity to specify minimum number of line segments a half circle is split into More...
 
TriMesh::Ptr createMesh (int resolution, double size) const
 Create a triangle mesh representing the plane. More...
 
virtual rw::math::Q getParameters () const
 get the parameters that define this primitive More...
 
virtual void setParameters (const rw::math::Q &q)
 set the parameters that define this primitive More...
 
GeometryType getType () const
 the type of this primitive More...
 
- Public Member Functions inherited from Primitive
virtual ~Primitive ()
 destructor
 
TriMesh::Ptr getTriMesh (bool forceCopy=true)
 gets a trimesh representation of this geometry data. More...
 
virtual bool isConvex ()
 test if this geometry data is convex More...
 
bool isInside (const rw::math::Vector3D< double > &point)
 test if a point is on the border or inside this primitive
 
- Public Member Functions inherited from GeometryData
virtual ~GeometryData ()
 Destructor.
 

Static Public Member Functions

static rw::math::Metric< Plane >::Ptr makeMetric (double angToDistWeight=1.0)
 Create a metric that can be used to compare distance between two planes. The distance between two planes is computed as follows: More...
 
- Static Public Member Functions inherited from GeometryData
static std::string toString (GeometryType type)
 format GeometryType to string More...
 

Protected Member Functions

bool doIsInside (const rw::math::Vector3D< double > &point)
 Check if point lies inside geometry. More...
 
- Protected Member Functions inherited from Primitive
 Primitive (int levels=20)
 Constructor. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const Plane &p)
 Streaming operator.
 

Detailed Description

plane primitive represented in Hessian normal-form: a*nx+b*ny+c*nz+d=0

Constructor & Destructor Documentation

◆ Plane() [1/4]

Plane ( )
inline

Constructor.

Makes a plane on X-Y surface.

◆ Plane() [2/4]

Plane ( const rw::math::Q q)
inline

constructor

Parameters
q

◆ Plane() [3/4]

Plane ( const rw::math::Vector3D< double > &  n,
const double  d 
)
inline

constructor

Parameters
n[in] normal of plane
d[in] distance from plane to (0,0,0) in direction of normal

◆ Plane() [4/4]

Plane ( const rw::math::Vector3D< double > &  p1,
const rw::math::Vector3D< double > &  p2,
const rw::math::Vector3D< double > &  p3 
)
inline

constructor - calculates the plane from 3 vertices

Parameters
p1[in] vertice 1
p2[in] vertice 2
p3[in] vertice 3

Member Function Documentation

◆ createMesh() [1/2]

TriMesh::Ptr createMesh ( int  resolution) const
virtual

make a trimesh from this primitive. Use granularity to specify minimum number of line segments a half circle is split into

Parameters
resolution[in]

Implements Primitive.

◆ createMesh() [2/2]

TriMesh::Ptr createMesh ( int  resolution,
double  size 
) const

Create a triangle mesh representing the plane.

Provides the posibility to specify the size of the plan.

Parameters
resolution[in] Resolution of the mesh (not applicable for a plane)
size[in] Size of the plane.

◆ distance() [1/2]

double distance ( const Plane plane) const
inline

Default metric for computing the difference between 2 planes.

Parameters
plane[in]

◆ distance() [2/2]

double distance ( const rw::math::Vector3D< double > &  point) const
inline

Calculates the shortest distance from point to plane.

The distance includes the sign s.t. a negative distance corresponds to point being behind the plane and a positive distance in front of the plane.

Parameters
point

◆ doIsInside()

bool doIsInside ( const rw::math::Vector3D< double > &  point)
inlineprotectedvirtual

Check if point lies inside geometry.

Parameters
point[in] point to check.
Returns
true if inside geometry, false otherwise.

Reimplemented from Primitive.

◆ getParameters()

virtual rw::math::Q getParameters ( ) const
virtual

get the parameters that define this primitive

Implements Primitive.

◆ getType()

GeometryType getType ( ) const
inlinevirtual

the type of this primitive

Implements GeometryData.

◆ intersection()

rw::math::Vector3D<double> intersection ( const rw::math::Vector3D< double > &  p1,
const rw::math::Vector3D< double > &  p2 
) const

Calculates the intersection between the line and plane.

The line defined by p1 and p2 is considered infinitely long. Throws a rw::core::Exception if the line is parallel to the plane.

Parameters
p1[in] point 1 on the line
p2[in] point 2 on the line

◆ makeMetric()

static rw::math::Metric<Plane>::Ptr makeMetric ( double  angToDistWeight = 1.0)
static

Create a metric that can be used to compare distance between two planes. The distance between two planes is computed as follows:

val = 0.5*angle(p1.normal, p2.normal)*angToDistWeight + 0.5*fabs(p1.d-p2.d);

Returns
distance metric

◆ refit()

double refit ( const std::vector< rw::math::Vector3D< double >> &  data)

Fit this plane to a set of points.

A PCA analysis of the points are made and the two axes with largest extends are used for defining the plane. The error is the sum of the squared mean of the points to the plane.

The plane normal always points in the positive z-direction.

Parameters
data[in] a set of points
Returns
fitting error

◆ setParameters()

virtual void setParameters ( const rw::math::Q q)
virtual

set the parameters that define this primitive

Implements Primitive.


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