Klamp't  0.9.0
Mass.h
1 #ifndef OBJECT_MASS_H
2 #define OBJECT_MASS_H
3 
4 #include <KrisLibrary/geometry/AnyGeometry.h>
5 
6 namespace Klampt {
7  using namespace Math3D;
8 
11 
14 Vector3 CenterOfMass(const Meshing::TriMesh& mesh,Real surfaceFraction=1.0);
16 Vector3 CenterOfMass(const Meshing::PointCloud3D& pc,Real surfaceFraction=1.0);
19 Vector3 CenterOfMass(const Meshing::VolumeGrid& grid,Real surfaceFraction=1.0);
21 Vector3 CenterOfMass(const Geometry::AnyGeometry3D& geom,Real surfaceFraction=1.0);
22 
24 Matrix3 Covariance(const Meshing::TriMesh& mesh,const Vector3& center,Real surfaceFraction=1.0);
25 Matrix3 Covariance(const Meshing::PointCloud3D& pc,const Vector3& center,Real surfaceFraction=1.0);
26 Matrix3 Covariance(const Meshing::VolumeGrid& vol,const Vector3& center,Real surfaceFraction=1.0);
27 Matrix3 Covariance(const Geometry::AnyGeometry3D& geom,const Vector3& center,Real surfaceFraction=1.0);
28 inline Matrix3 Covariance(const Meshing::TriMesh& mesh,Real surfaceFraction=1.0) { return Covariance(mesh,CenterOfMass(mesh,surfaceFraction),surfaceFraction); }
29 inline Matrix3 Covariance(const Meshing::PointCloud3D& mesh,Real surfaceFraction=1.0) { return Covariance(mesh,CenterOfMass(mesh,surfaceFraction),surfaceFraction); }
30 inline Matrix3 Covariance(const Meshing::VolumeGrid& mesh,Real surfaceFraction=1.0) { return Covariance(mesh,CenterOfMass(mesh,surfaceFraction),surfaceFraction); }
31 inline Matrix3 Covariance(const Geometry::AnyGeometry3D& mesh,Real surfaceFraction=1.0) { return Covariance(mesh,CenterOfMass(mesh,surfaceFraction),surfaceFraction); }
32 
34 Matrix3 Inertia(const Meshing::TriMesh& mesh,const Vector3& center,Real mass,Real surfaceFraction=1.0);
35 Matrix3 Inertia(const Meshing::PointCloud3D& mesh,const Vector3& center,Real mass,Real surfaceFraction=1.0);
36 Matrix3 Inertia(const Meshing::VolumeGrid& mesh,const Vector3& center,Real mass,Real surfaceFraction=1.0);
37 Matrix3 Inertia(const Geometry::AnyGeometry3D& mesh,const Vector3& center,Real mass,Real surfaceFraction=1.0);
38 inline Matrix3 Inertia(const Meshing::TriMesh& mesh,Real mass,Real surfaceFraction=1.0) { return Inertia(mesh,CenterOfMass(mesh,surfaceFraction),mass,surfaceFraction); }
39 inline Matrix3 Inertia(const Meshing::PointCloud3D& mesh,Real mass,Real surfaceFraction=1.0) { return Inertia(mesh,CenterOfMass(mesh,surfaceFraction),mass,surfaceFraction); }
40 inline Matrix3 Inertia(const Meshing::VolumeGrid& mesh,Real mass,Real surfaceFraction=1.0) { return Inertia(mesh,CenterOfMass(mesh,surfaceFraction),mass,surfaceFraction); }
41 inline Matrix3 Inertia(const Geometry::AnyGeometry3D& mesh,Real mass,Real surfaceFraction=1.0) { return Inertia(mesh,CenterOfMass(mesh,surfaceFraction),mass,surfaceFraction); }
42 
45 Vector3 CenterOfMass_Solid(const Meshing::TriMesh& mesh,Real gridRes);
48 Matrix3 Covariance_Solid(const Meshing::TriMesh& mesh,Real gridRes,const Vector3& center);
49 inline Matrix3 Covariance_Solid(const Meshing::TriMesh& mesh,Real gridRes)
50 {
51  return Covariance_Solid(mesh,gridRes,CenterOfMass_Solid(mesh,gridRes));
52 }
55 Matrix3 Inertia_Solid(const Meshing::TriMesh& mesh,Real gridRes,const Vector3& center,Real mass);
56 inline Matrix3 Inertia_Solid(const Meshing::TriMesh& mesh,Real gridRes,Real mass)
57 {
58  return Inertia_Solid(mesh,gridRes,CenterOfMass_Solid(mesh,gridRes),mass);
59 }
60 
63 } //namespace Klampt
64 
65 #endif
Matrix3 Inertia_Solid(const Meshing::TriMesh &mesh, Real gridRes, const Vector3 &center, Real mass)
Matrix3 Covariance(const Meshing::TriMesh &mesh, const Vector3 &center, Real surfaceFraction=1.0)
Computes the second moment integrated over the geometry.
Vector3 CenterOfMass_Solid(const Meshing::TriMesh &mesh, Real gridRes)
Matrix3 Inertia(const Meshing::TriMesh &mesh, const Vector3 &center, Real mass, Real surfaceFraction=1.0)
Computes the inertia tensor by integrating over the mesh.
Matrix3 Covariance_Solid(const Meshing::TriMesh &mesh, Real gridRes, const Vector3 &center)
Vector3 CenterOfMass(const Geometry::AnyGeometry3D &geom, Real surfaceFraction=1.0)
Computes the first moment integrated over the geometry.
Definition: ContactDistance.h:6