RobWorkProject  23.9.11-
Static Public Member Functions | List of all members
GeometryUtil Class Reference

Utility functions for calculating properties of geometry. More...

#include <GeometryUtil.hpp>

Static Public Member Functions

static double estimateVolume (const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &geoms)
 Estimates the volume of a list of geometries. More...
 
static double estimateVolume (const rw::geometry::TriMesh &trimesh)
 Estimates the volume of a trimesh. More...
 
static std::pair< rw::math::Vector3D< double >, rw::math::InertiaMatrix<> > estimateInertiaCOG (double mass, const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &geoms, const rw::core::Ptr< rw::kinematics::Frame > ref, const rw::kinematics::State &state, const rw::math::Transform3D<> &reftrans=rw::math::Transform3D<>::identity())
 Estimates the inertia and center of gravity (COG) of a list of geometries. More...
 
static rw::math::InertiaMatrix estimateInertia (double mass, const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &geoms, const rw::core::Ptr< rw::kinematics::Frame > ref, const rw::kinematics::State &state, const rw::math::Transform3D<> &reftrans=rw::math::Transform3D<>::identity())
 Estimates the inertia of a list of geometries. More...
 
static rw::math::InertiaMatrix estimateInertia (double mass, const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &geoms, const rw::math::Transform3D<> &reftrans=rw::math::Transform3D<>::identity())
 Estimates the inertia of a list of geometries. More...
 
template<class T >
static std::pair< rw::math::Rotation3D< T >, rw::math::Vector3D< T > > calculatePrincipalInertia (const rw::math::InertiaMatrix< T > &inertia)
 Find the principal axes and the principal inertia. More...
 
static rw::math::Vector3D< double > estimateCOG (const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &geoms)
 Estimates the center of gravity (COG) of a list of geometries. More...
 
static rw::math::Vector3D< double > estimateCOG (const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &geoms, const rw::core::Ptr< rw::kinematics::Frame > ref, const rw::kinematics::State &state)
 Estimates the center of gravity (COG) of a list of geometries. More...
 
static rw::math::Vector3D< double > estimateCOG (const TriMesh &trimesh, const rw::math::Transform3D<> &t3d=rw::math::Transform3D<>::identity())
 Estimates the center of gravity (COG) of a triangle mesh. More...
 
static double calcMaxDist (const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &geoms, const rw::math::Vector3D< double > center, rw::core::Ptr< rw::kinematics::Frame > ref, const rw::kinematics::State &state)
 calculates the max distance to any triangle in the geoms, from some point center More...
 
static std::vector< rw::kinematics::Frame * > getAnchoredFrames (rw::kinematics::Frame &f, const rw::kinematics::State &state)
 util function that locates all frames that is staticly connected to f and that has geometry information.
 
static std::vector< rw::kinematics::Frame * > getAnchoredChildFrames (rw::core::Ptr< rw::kinematics::Frame > parent, const rw::kinematics::State &state)
 util function that locates all frames in the sub tree of parent that is staticly connected and that has geometry information.
 
template<std::size_t N>
static double simplexVolume (const std::vector< rw::math::VectorND< N >> &vertices)
 calculates volume of k-simplex More...
 
static std::pair< rw::math::Vector3D< double >, rw::math::Vector3D< double > > getExtremumDistances (rw::core::Ptr< TriMesh > trimesh, const rw::math::Transform3D<> &t3d=rw::math::Transform3D<>::identity())
 Returns the extremum distances for the vertices of the TriMesh given the specified transformation. More...
 
static rw::math::Vector3D< double > getDimensions (rw::core::Ptr< rw::geometry::Geometry > geometry)
 Returns the dimensions of geometry. More...
 
static rw::math::Vector3D< double > getDimensions (rw::core::Ptr< TriMesh > trimesh)
 Returns the dimensions of trimesh. More...
 
template<std::size_t N>
static double actualSimplexVolume (const std::vector< rw::math::VectorND< N >> &vertices)
 Calculates the volume of a N-simplex. Volume of a N-simplex is calculated as: \( V_{Simplex} = \frac{|W|}{N!} \), where: More...
 

Detailed Description

Utility functions for calculating properties of geometry.

The methods for calculation of volume, inertia, and the center of gravity, is as described in [1].

[1]: Fast and Accurate Computation of Polyhedral Mass Properties, Brian Mirtich. Journal of Graphics Tools, Vol.1, pages 31-58, 1996

Member Function Documentation

◆ actualSimplexVolume()

static double actualSimplexVolume ( const std::vector< rw::math::VectorND< N >> &  vertices)
inlinestatic

Calculates the volume of a N-simplex. Volume of a N-simplex is calculated as: \( V_{Simplex} = \frac{|W|}{N!} \), where:

\( W \) is the N*N matrix \( [v_{1}-v_{0} , \:v_{i}-v_{0}\:\cdots\: , v_{N}-v_{0}] \) Where \( v_{i} \) is the i'th vertic given. This function can be supplied with N and N+1 vertices. If only N vertices are given, then the volume is calculated with the origo as the remaining vertex. (See https://en.wikipedia.org/wiki/Simplex#Volume)

◆ calcMaxDist()

static double calcMaxDist ( const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &  geoms,
const rw::math::Vector3D< double >  center,
rw::core::Ptr< rw::kinematics::Frame ref,
const rw::kinematics::State state 
)
static

calculates the max distance to any triangle in the geoms, from some point center

Parameters
geoms[in] the geometries containing the triangles
center[in] the point to calculate the distance from
ref[in] the reference frame.
state
Returns
the maximum distance to any triangle in the geometries

◆ calculatePrincipalInertia()

static std::pair<rw::math::Rotation3D<T>, rw::math::Vector3D<T> > calculatePrincipalInertia ( const rw::math::InertiaMatrix< T > &  inertia)
inlinestatic

Find the principal axes and the principal inertia.

Parameters
inertia[in] the inertia matrix to calculate principal values for.
Returns
a rotation matrix giving the principal axes, and a vector of principal inertia values for these axes.

◆ estimateCOG() [1/3]

static rw::math::Vector3D<double> estimateCOG ( const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &  geoms)
static

Estimates the center of gravity (COG) of a list of geometries.

The COG will be found relative to the geometry frame.

Note
The geometries should be defined relative to the same frame - otherwise the result will not make sense.
Parameters
geoms[in] the list of geometries.
Returns
the center of gravity for the geometries.

◆ estimateCOG() [2/3]

static rw::math::Vector3D<double> estimateCOG ( const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &  geoms,
const rw::core::Ptr< rw::kinematics::Frame ref,
const rw::kinematics::State state 
)
static

Estimates the center of gravity (COG) of a list of geometries.

The COG will be given relative to the given reference frame.

Parameters
geoms[in] the list of geometries.
ref[in] the reference frame.
state[in] the state which gives the position of the geometries relative to the reference frame.
Returns
the center of gravity for the geometries.

◆ estimateCOG() [3/3]

static rw::math::Vector3D<double> estimateCOG ( const TriMesh trimesh,
const rw::math::Transform3D<> &  t3d = rw::math::Transform3D<>::identity() 
)
static

Estimates the center of gravity (COG) of a triangle mesh.

Parameters
trimesh[in] the triangle mesh.
t3d[in] (optional) make a transformation of the trimesh.
Returns
the center of gravity of the mesh.

◆ estimateInertia() [1/2]

static rw::math::InertiaMatrix estimateInertia ( double  mass,
const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &  geoms,
const rw::core::Ptr< rw::kinematics::Frame ref,
const rw::kinematics::State state,
const rw::math::Transform3D<> &  reftrans = rw::math::Transform3D<>::identity() 
)
static

Estimates the inertia of a list of geometries.

The inertia is described relative to the ref coordinate system The reftrans parameter can however be used to transform the geometries.

Parameters
mass[in] the total mass of all geometries.
geoms[in] the list of geometries.
ref[in] the reference frame for the geometries (if NULL, it is assumed that the geometries are defined relative to the same frame).
state[in] state used to retrieve the current location of geometries relative to the reference frame (only used if ref is given).
reftrans[in] (optional) used to transform the geometry before calculation of the inertia.
Returns
the inertia around relative to the ref frame.

◆ estimateInertia() [2/2]

static rw::math::InertiaMatrix estimateInertia ( double  mass,
const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &  geoms,
const rw::math::Transform3D<> &  reftrans = rw::math::Transform3D<>::identity() 
)
static

Estimates the inertia of a list of geometries.

The inertia is described relative to the geometry reference frame. The reftrans parameter can however be used to transform the geometries.

Note
The geometries should be defined relative to the same frame - otherwise the result will not make sense.
Parameters
mass[in] the total mass of all geometries.
geoms[in] the list of geometries.
reftrans[in] (optional) used to transform the geometry before calculation of the inertia.
Returns
the inertia matrix relative to the reference frame.

◆ estimateInertiaCOG()

static std::pair<rw::math::Vector3D<double>, rw::math::InertiaMatrix<> > estimateInertiaCOG ( double  mass,
const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &  geoms,
const rw::core::Ptr< rw::kinematics::Frame ref,
const rw::kinematics::State state,
const rw::math::Transform3D<> &  reftrans = rw::math::Transform3D<>::identity() 
)
static

Estimates the inertia and center of gravity (COG) of a list of geometries.

The inertia is described relative to the ref coordinate system translated to COG. The reftrans parameter can however be used to transform the geometries.

Parameters
mass[in] the total mass of all geometries.
geoms[in] the list of geometries.
ref[in] the reference frame for the geometries (if NULL, it is assumed that the geometries are defined relative to the same frame).
state[in] state used to retrieve the current location of geometries relative to the reference frame (only used if ref is given).
reftrans[in] (optional) used to transform the geometry before calculation of the inertia.
Returns
the center of gravity relative to the ref frame and the inertia around the center of gravity (in the coordinate frame of the ref frame).

◆ estimateVolume() [1/2]

static double estimateVolume ( const rw::geometry::TriMesh trimesh)
static

Estimates the volume of a trimesh.

Parameters
trimesh[in] the trimesh.
Returns
the total volume of the trimesh.

◆ estimateVolume() [2/2]

static double estimateVolume ( const std::vector< rw::core::Ptr< rw::geometry::Geometry >> &  geoms)
static

Estimates the volume of a list of geometries.

Note
If geometries are overlapping, the overlapping regions will count twice in the volume.
Parameters
geoms[in] the list of geometries.
Returns
the total volume of the geometries.

◆ getDimensions() [1/2]

static rw::math::Vector3D<double> getDimensions ( rw::core::Ptr< rw::geometry::Geometry geometry)
static

Returns the dimensions of geometry.

Parameters
geometry[in] Geometry to analyse
Returns
Dimensions in the x,y and z directions.

◆ getDimensions() [2/2]

static rw::math::Vector3D<double> getDimensions ( rw::core::Ptr< TriMesh trimesh)
static

Returns the dimensions of trimesh.

Parameters
trimesh[in] TriMesh to analyse
Returns
Dimensions in the x,y and z directions.

◆ getExtremumDistances()

static std::pair<rw::math::Vector3D<double>, rw::math::Vector3D<double> > getExtremumDistances ( rw::core::Ptr< TriMesh trimesh,
const rw::math::Transform3D<> &  t3d = rw::math::Transform3D<>::identity() 
)
static

Returns the extremum distances for the vertices of the TriMesh given the specified transformation.

Parameters
trimesh[in] TriMesh to find extremum distances for
t3d[in] Transformation of the vertices
Returns
Pair containing the lower and upper extremum distances of the vertices.

◆ simplexVolume()

static double simplexVolume ( const std::vector< rw::math::VectorND< N >> &  vertices)
inlinestatic

calculates volume of k-simplex

Warning
What is meant by volume is not really volume, see "actualSimplexVolume" - if you want the volume. Read the documentation (preferably code), to make sure you get what you want.

Volume of k-dimensional simplex (triangle is 2-simplex) is calculated as: \( V(S) = \frac{1}{k!} \sqrt{W W^T}\), where:

\( W \) is a matrix consisting of rows

\(w_i = [v_{i,1}-v_{0,1}\:v_{i,2}-v_{0, 2}\:\cdots\:v_{i,k+1}-v_{0,k+1}] \)

of i-th vertex coordinates. (taken from: http://www.math.niu.edu/~rusin/known-math/97/volumes.polyh) (dead link)


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