Package org.robwork.sdurw_geometry
Class GeometryUtil
- java.lang.Object
-
- org.robwork.sdurw_geometry.GeometryUtil
-
public class GeometryUtil extends java.lang.Object
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
-
-
Constructor Summary
Constructors Constructor Description GeometryUtil()
GeometryUtil(long cPtr, boolean cMemoryOwn)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static double
calcMaxDist(VectorGeometryPtr geoms, Vector3D center, FramePtr ref, State state)
calculates the max distance to any triangle in the geoms, from some point
centervoid
delete()
static Vector3D
estimateCOG(TriMesh trimesh)
Estimates the center of gravity (COG) of a triangle mesh.static Vector3D
estimateCOG(TriMesh trimesh, Transform3D t3d)
Estimates the center of gravity (COG) of a triangle mesh.static Vector3D
estimateCOG(VectorGeometryPtr geoms)
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.
static Vector3D
estimateCOG(VectorGeometryPtr geoms, FramePtr ref, State state)
Estimates the center of gravity (COG) of a list of geometries.
The COG will be given relative to the given reference frame.
static InertiaMatrixd
estimateInertia(double mass, VectorGeometryPtr geoms)
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.
static InertiaMatrixd
estimateInertia(double mass, VectorGeometryPtr geoms, FramePtr ref, State state)
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.
static InertiaMatrixd
estimateInertia(double mass, VectorGeometryPtr geoms, FramePtr ref, State state, Transform3D reftrans)
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.
static InertiaMatrixd
estimateInertia(double mass, VectorGeometryPtr geoms, Transform3D reftrans)
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.
static SWIGTYPE_p_std__pairT_rw__math__Vector3DT_double_t_rw__math__InertiaMatrixT_double_t_t
estimateInertiaCOG(double mass, VectorGeometryPtr geoms, FramePtr ref, State state)
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.
static SWIGTYPE_p_std__pairT_rw__math__Vector3DT_double_t_rw__math__InertiaMatrixT_double_t_t
estimateInertiaCOG(double mass, VectorGeometryPtr geoms, FramePtr ref, State state, Transform3D reftrans)
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.
static double
estimateVolume(TriMesh trimesh)
Estimates the volume of a trimesh.static double
estimateVolume(VectorGeometryPtr geoms)
Estimates the volume of a list of geometries.
Note: If geometries are overlapping, the overlapping regions will count twice in the
volume.static FrameVector
getAnchoredChildFrames(FramePtr parent, State state)
util function that locates all frames in the sub tree of parent
that is staticly connected and that has geometry information.static FrameVector
getAnchoredFrames(Frame f, State state)
util function that locates all frames that is staticly connected to f
and that has geometry information.static long
getCPtr(GeometryUtil obj)
static Vector3D
getDimensions(GeometryPtr geometry)
Returns the dimensions of geometrystatic Vector3D
getDimensions(TriMeshPtr trimesh)
Returns the dimensions of trimeshstatic SWIGTYPE_p_std__pairT_rw__math__Vector3DT_double_t_rw__math__Vector3DT_double_t_t
getExtremumDistances(TriMeshPtr trimesh)
Returns the extremum distances for the vertices of the TriMesh given the specified
transformationstatic SWIGTYPE_p_std__pairT_rw__math__Vector3DT_double_t_rw__math__Vector3DT_double_t_t
getExtremumDistances(TriMeshPtr trimesh, Transform3D t3d)
Returns the extremum distances for the vertices of the TriMesh given the specified
transformation
-
-
-
Method Detail
-
getCPtr
public static long getCPtr(GeometryUtil obj)
-
delete
public void delete()
-
estimateVolume
public static double estimateVolume(VectorGeometryPtr geoms)
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.
-
estimateVolume
public static double estimateVolume(TriMesh trimesh)
Estimates the volume of a trimesh.- Parameters:
trimesh
- [in] the trimesh.- Returns:
- the total volume of the trimesh.
-
estimateInertiaCOG
public static SWIGTYPE_p_std__pairT_rw__math__Vector3DT_double_t_rw__math__InertiaMatrixT_double_t_t estimateInertiaCOG(double mass, VectorGeometryPtr geoms, FramePtr ref, State state, Transform3D reftrans)
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).
-
estimateInertiaCOG
public static SWIGTYPE_p_std__pairT_rw__math__Vector3DT_double_t_rw__math__InertiaMatrixT_double_t_t estimateInertiaCOG(double mass, VectorGeometryPtr geoms, FramePtr ref, State state)
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).
- 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).
-
estimateInertia
public static InertiaMatrixd estimateInertia(double mass, VectorGeometryPtr geoms, FramePtr ref, State state, Transform3D reftrans)
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
public static InertiaMatrixd estimateInertia(double mass, VectorGeometryPtr geoms, FramePtr ref, State state)
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).
- Returns:
- the inertia around relative to the ref frame.
-
estimateInertia
public static InertiaMatrixd estimateInertia(double mass, VectorGeometryPtr geoms, Transform3D reftrans)
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.
-
estimateInertia
public static InertiaMatrixd estimateInertia(double mass, VectorGeometryPtr geoms)
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.
- Returns:
- the inertia matrix relative to the reference frame.
-
estimateCOG
public static Vector3D estimateCOG(VectorGeometryPtr geoms)
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
public static Vector3D estimateCOG(VectorGeometryPtr geoms, FramePtr ref, State state)
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
public static Vector3D estimateCOG(TriMesh trimesh, Transform3D t3d)
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.
-
estimateCOG
public static Vector3D estimateCOG(TriMesh trimesh)
Estimates the center of gravity (COG) of a triangle mesh.- Parameters:
trimesh
- [in] the triangle mesh.
- Returns:
- the center of gravity of the mesh.
-
calcMaxDist
public static double calcMaxDist(VectorGeometryPtr geoms, Vector3D center, FramePtr ref, State state)
calculates the max distance to any triangle in the geoms, from some point
center- Parameters:
geoms
- [in] the geometries containing the trianglescenter
- [in] the point to calculate the distance fromref
- [in] the reference frame.state
-- Returns:
- the maximum distance to any triangle in the geometries
-
getAnchoredFrames
public static FrameVector getAnchoredFrames(Frame f, State state)
util function that locates all frames that is staticly connected to f
and that has geometry information.
-
getAnchoredChildFrames
public static FrameVector getAnchoredChildFrames(FramePtr parent, State state)
util function that locates all frames in the sub tree of parent
that is staticly connected and that has geometry information.
-
getExtremumDistances
public static SWIGTYPE_p_std__pairT_rw__math__Vector3DT_double_t_rw__math__Vector3DT_double_t_t getExtremumDistances(TriMeshPtr trimesh, Transform3D t3d)
Returns the extremum distances for the vertices of the TriMesh given the specified
transformation- Parameters:
trimesh
- [in] TriMesh to find extremum distances fort3d
- [in] Transformation of the vertices- Returns:
- Pair containing the lower and upper extremum distances of the vertices.
-
getExtremumDistances
public static SWIGTYPE_p_std__pairT_rw__math__Vector3DT_double_t_rw__math__Vector3DT_double_t_t getExtremumDistances(TriMeshPtr trimesh)
Returns the extremum distances for the vertices of the TriMesh given the specified
transformation- Parameters:
trimesh
- [in] TriMesh to find extremum distances for
- Returns:
- Pair containing the lower and upper extremum distances of the vertices.
-
getDimensions
public static Vector3D getDimensions(GeometryPtr geometry)
Returns the dimensions of geometry- Parameters:
geometry
- [in] Geometry to analyse- Returns:
- Dimensions in the x,y and z directions.
-
getDimensions
public static Vector3D getDimensions(TriMeshPtr trimesh)
Returns the dimensions of trimesh- Parameters:
trimesh
- [in] TriMesh to analyse- Returns:
- Dimensions in the x,y and z directions.
-
-