RobWorkProject  22.2.21-
Public Types | Public Member Functions | List of all members
ImplicitTorus Class Reference

Torus defined as an implicit surface. More...

#include <ImplicitTorus.hpp>

Inherits ImplicitSurface.

Public Types

typedef rw::core::Ptr< ImplicitTorusPtr
 Smart pointer type for ImplicitTorus.
 
typedef rw::core::Ptr< const ImplicitTorusCPtr
 Smart pointer type for const ImplicitTorus.
 
typedef ImplicitSurface::CPtr TrimmingRegion
 A trimming region is defined using an ImplicitSurface. More...
 
- Public Types inherited from ImplicitSurface
typedef rw::core::Ptr< ImplicitSurfacePtr
 Smart pointer type for ImplicitSurface.
 
typedef rw::core::Ptr< const ImplicitSurfaceCPtr
 Smart pointer type for const ImplicitSurface.
 
- Public Types inherited from Surface
typedef rw::core::Ptr< SurfacePtr
 Smart pointer type for Surface.
 
typedef rw::core::Ptr< const SurfaceCPtr
 Smart pointer type for const Surface.
 

Public Member Functions

 ImplicitTorus (double R, double r)
 Construct circular torus. More...
 
 ImplicitTorus (double R1, double R2, double r1, double r2)
 Construct elliptic torus. More...
 
virtual ~ImplicitTorus ()
 Destructor.
 
ImplicitTorus::Ptr transform (const rw::math::Transform3D<> &T) const
 
ImplicitTorus::Ptr transform (const rw::math::Vector3D< double > &P) const
 Move the surface without rotation. More...
 
ImplicitTorus::Ptr scale (double factor) const
 Get a scaled version of the surface. More...
 
ImplicitTorus::Ptr clone () const
 Clone the surface. More...
 
virtual std::pair< double, double > extremums (const rw::math::Vector3D< double > &direction) const
 Find the extent of the surface along a specific direction. More...
 
virtual rw::core::Ptr< TriMeshgetTriMesh (const std::vector< rw::math::Vector3D< double > > &border=std::vector< rw::math::Vector3D< double > >()) const
 Discretize the surface into a triangle mesh representation. More...
 
virtual void setDiscretizationResolution (double resolution)
 Set the resolution used for discretization in the getTriMesh function. More...
 
virtual bool equals (const Surface &surface, double threshold) const
 Check if this surface is identical to other surface . More...
 
virtual double operator() (const rw::math::Vector3D< double > &x) const
 Evaluate the implicit function, \( F(\mathbf{x}) \), for the surface. More...
 
virtual bool insideTrimmingRegion (const rw::math::Vector3D< double > &P) const
 Check if point, P, on surface lies inside the trimming region. More...
 
virtual rw::math::Vector3D< double > normal (const rw::math::Vector3D< double > &x) const
 Get the normal of the surface at a specific point, x, lying on the surface. More...
 
virtual rw::math::Vector3D< double > gradient (const rw::math::Vector3D< double > &x) const
 Get the gradient, \(\nabla \mathbf{F}\), of the surface at a specific point, x, lying on the surface. More...
 
virtual void reuseTrimmingRegions (rw::geometry::ImplicitSurface::Ptr surface) const
 Let other surface reuse this surfaces trimming regions, if there are identical region definitions. More...
 
const std::vector< TrimmingRegion > & getTrimmingConditions () const
 Get the trimming conditions for the surface. More...
 
void setTrimmingConditions (const std::vector< TrimmingRegion > &conditions)
 Set the trimming conditions of this surface. More...
 
void addTrimmingCondition (const TrimmingRegion &condition)
 Add a trimming condition to this surface. More...
 
- Public Member Functions inherited from ImplicitSurface
 ImplicitSurface ()
 Constructor.
 
virtual ~ImplicitSurface ()
 Destructor.
 
ImplicitSurface::Ptr transform (const rw::math::Transform3D<> &T) const
 
ImplicitSurface::Ptr transform (const rw::math::Vector3D< double > &P) const
 Move the surface without rotation. More...
 
ImplicitSurface::Ptr scale (double factor) const
 Get a scaled version of the surface. More...
 
ImplicitSurface::Ptr clone () const
 Clone the surface. More...
 
- Public Member Functions inherited from Surface
 Surface ()
 Constructor.
 
virtual ~Surface ()
 Destructor.
 
Surface::Ptr transform (const rw::math::Transform3D< double > &T) const
 Move the surface. More...
 
Surface::Ptr transform (const rw::math::Vector3D< double > &P) const
 Move the surface without rotation. More...
 
Surface::Ptr scale (double factor) const
 Get a scaled version of the surface. More...
 
Surface::Ptr clone () const
 Clone the surface. More...
 

Detailed Description

Torus defined as an implicit surface.

The torus is described as an implicit surface of the form:

\( \left(x^T x + R^2 - r^2 \right)^2 - 4 R^2 x^T \begin{bmatrix} 1 & 0 & 0\\ 0 & 1 & 0 \\ 0 & 0 & 0 \end{bmatrix} x = 0\)

or equivalently:

\( \left(x^T x - R^2 - r^2 \right)^2 - 4 R^2 (r^2 - {x_3}^2) = 0\)

where R is the distance from the center of the torus to the center of the tube, r is the radius of the tube, and \( x \in \mathbb{R}^3\).

Standard circular torus with circular tube.

Alternatively, a torus with an elliptic tube can be specified. This surface has the more generic form:

\( \left( x^T \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & \frac{{r_1}^2}{{r_2}^2} \end{bmatrix} x + R^2 - {r_1}^2 \right)^2 - 4 R^2 x^T \begin{bmatrix} 1 & 0 & 0\\ 0 & 1 & 0 \\ 0 & 0 & 0 \end{bmatrix} x = 0\)

or equivalently:

\( \left( x^T \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & \frac{{r_1}^2}{{r_2}^2} \end{bmatrix} x - R^2 - {r_1}^2 \right)^2 - 4 R^2 \left({r_1}^2 - \frac{{r_1}^2}{{r_2}^2} {x_3}^2 \right) = 0\)

Circular torus with elliptic tube.

The elliptic torus with elliptic tube has the much more complex form:

\( \left( ({R_2}^2+t){x_1}^2 + ({R_1}^2+t){x_2}^2 - ({R_1}^2+t)({R_2}^2+t) - 4 R_1 R_2 t \right)^2 - 4 t (R_2 {x_1}^2 + R_1 {x_2}^2 - (R_1+R_2)(R_1 R_2 + t))^2 = 0\)

where

\( t = {r_1}^2 (1-\frac{{x_3}^2}{{r_2}^2}) \)

Elliptic torus with elliptic tube.

Notice that many functions are not yet implemented for this last type of elliptic torus. These functions might throw an exception.

Member Typedef Documentation

◆ TrimmingRegion

A trimming region is defined using an ImplicitSurface.

A point is only considered part of this surface, if all trimming conditions evaluate to a negative value.

Constructor & Destructor Documentation

◆ ImplicitTorus() [1/2]

ImplicitTorus ( double  R,
double  r 
)

Construct circular torus.

Parameters
R[in] distance from center of torus to center of tube.
r[in] radius of the tube.

◆ ImplicitTorus() [2/2]

ImplicitTorus ( double  R1,
double  R2,
double  r1,
double  r2 
)

Construct elliptic torus.

Parameters
R1[in] distance from center of torus to center of tube in first direction.
R2[in] distance from center of torus to center of tube in second direction.
r1[in] radius of the tube in first direction.
r2[in] radius of the tube in second direction.

Member Function Documentation

◆ addTrimmingCondition()

void addTrimmingCondition ( const TrimmingRegion condition)
inline

Add a trimming condition to this surface.

Parameters
condition[in] the condition to add.

◆ clone()

ImplicitTorus::Ptr clone ( ) const

Clone the surface.

Returns
pointer to copy of surface.

◆ equals()

virtual bool equals ( const Surface surface,
double  threshold 
) const
virtual

Check if this surface is identical to other surface .

Parameters
surface[in] other surface to compare to.
threshold[in] threshold for when surfaces can be considered identical.
Returns
true if identical, false otherwise.

Implements ImplicitSurface.

◆ extremums()

virtual std::pair< double, double > extremums ( const rw::math::Vector3D< double > &  direction) const
virtual

Find the extent of the surface along a specific direction.

If the surface has no lower bound, the value -std::numeric_limits<double>::max() can be returned to indicate that the surface has unbounded minimum value in the given direction.

If the surface has no upper bound, the value std::numeric_limits<double>::max() can be returned to indicate that the surface has unbounded maximum value in the given direction.

Parameters
direction[in] a normalized direction vector.
Returns
the minimum and maximum values along the given direction.
Note
This function does not take trimming conditions into account. For trimmed surfaces, create a Face with the boundary curves and use Face::extremums.

Implements ImplicitSurface.

◆ getTriMesh()

virtual rw::core::Ptr< TriMesh > getTriMesh ( const std::vector< rw::math::Vector3D< double > > &  border = std::vector< rw::math::Vector3D< double > >()) const
virtual

Discretize the surface into a triangle mesh representation.

If the border of a trimmed surface must fit with other surface triangulations, a discretized border must be given to this triangulation function.

If the same border points are used for different surfaces for their common edges, the triangulations will fit together.

Parameters
border[in] (optional) an ordered list of points on the surface, that forms the border of the patch to triangulate.
Returns
a new TriMesh.

Implements ImplicitSurface.

◆ getTrimmingConditions()

const std::vector< TrimmingRegion >& getTrimmingConditions ( ) const
inline

Get the trimming conditions for the surface.

Returns
ImplicitSurface vector specifying the boundary of the surface. If surface is unbounded, the length of the vector is zero.

◆ gradient()

virtual rw::math::Vector3D<double> gradient ( const rw::math::Vector3D< double > &  x) const
virtual

Get the gradient, \(\nabla \mathbf{F}\), of the surface at a specific point, x, lying on the surface.

The gradient is the vector of partial derivatives \( \nabla \mathbf{F} = \begin{bmatrix}\frac{\partial F}{\partial x} & \frac{\partial F}{\partial y} & \frac{\partial F}{\partial z} \end{bmatrix}^T \)

Parameters
x[in] a point on the surface.
Returns
the gradient, \(\nabla \mathbf{F}\), of the surface at x .
See also
the normal function to find the normal to the surface (the normalized gradient).

Implements ImplicitSurface.

◆ insideTrimmingRegion()

virtual bool insideTrimmingRegion ( const rw::math::Vector3D< double > &  P) const
virtual

Check if point, P, on surface lies inside the trimming region.

Parameters
P[in] the point to check.
Returns
true if the points lies inside the trimming region.

Reimplemented from ImplicitSurface.

◆ normal()

virtual rw::math::Vector3D<double> normal ( const rw::math::Vector3D< double > &  x) const
virtual

Get the normal of the surface at a specific point, x, lying on the surface.

For the point on the implicit surface, where \( F(\mathbf{x})=0 \) , the normal is the direction of the gradient \(\frac{\nabla \mathbf{F}}{\|\nabla \mathbf{F}\|}\) .

Parameters
x[in] a point on the surface.
Returns
the normal to the surface at x .
See also
the gradient function to find the gradient.

Reimplemented from ImplicitSurface.

◆ operator()()

virtual double operator() ( const rw::math::Vector3D< double > &  x) const
virtual

Evaluate the implicit function, \( F(\mathbf{x}) \), for the surface.

Parameters
x[in] the point to evaluate.
Returns
the value of the implicit function. If smaller than zero, x lies inside the surface. If larger than zero, x lies outside the surface.

Implements ImplicitSurface.

◆ reuseTrimmingRegions()

virtual void reuseTrimmingRegions ( rw::geometry::ImplicitSurface::Ptr  surface) const
virtual

Let other surface reuse this surfaces trimming regions, if there are identical region definitions.

This allows for some implementations to save a small amount of memory.

Parameters
surface[in/out] the other surface.

Reimplemented from ImplicitSurface.

◆ scale()

ImplicitTorus::Ptr scale ( double  factor) const

Get a scaled version of the surface.

Parameters
factor[in] the factor to scale with.
Returns
a new scaled surface.

◆ setDiscretizationResolution()

virtual void setDiscretizationResolution ( double  resolution)
inlinevirtual

Set the resolution used for discretization in the getTriMesh function.

The meaning of this parameter depends on the type of surface.

Parameters
resolution[in] the resolution parameter.

Implements ImplicitSurface.

◆ setTrimmingConditions()

void setTrimmingConditions ( const std::vector< TrimmingRegion > &  conditions)
inline

Set the trimming conditions of this surface.

Parameters
conditions[in] a vector of conditions.

◆ transform() [1/2]

ImplicitTorus::Ptr transform ( const rw::math::Transform3D<> &  T) const

◆ transform() [2/2]

ImplicitTorus::Ptr transform ( const rw::math::Vector3D< double > &  P) const

Move the surface without rotation.

If there is no rotation, this function is better to use than transform(const rw::math::Transform3D<>&) const for some surfaces. This is because certain properties can be preserved.

Parameters
P[in] the translation vector to the new surface.
Returns
pointer to a new surface.

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