对于一个系统全局属性有:
-
质量(mass)
-
质心(mass center)
-
惯性张量(matrix of inertia)
-
关于一个轴的矩(moment about an axis)
-
关于一个轴的惯性半径(radius of gyration about an axis)
-
惯性的主属性,比如主轴(principal axis),主矩(principal moments)和主惯性半径(principal radius of gyration)
在Open CASCADE Technology (OCCT)中,全局属性(如尺寸、质量、质心、惯性矩等)的计算是通过BRepGProp库来实现的。这个库提供了函数来计算几何形状的各种属性。
#include <TopoDS.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <GProp_GProps.hxx>
#include <BRepGProp.hxx>
#include <GProp_PrincipalProps.hxx>
#include"Viewer.h"
int main(int argc, char* argv[])
{
TopoDS_Shape box = BRepPrimAPI_MakeBox(1,2,3);
GProp_GProps System;
BRepGProp::LinearProperties(box, System);
BRepGProp::SurfaceProperties(box, System);
BRepGProp::VolumeProperties(box, System);
BRepGProp::VolumeProperties(box, System);
double out=System.Mass();
gp_Pnt G = System.CentreOfMass();
GProp_PrincipalProps Pp = System.PrincipalProperties();
double Ixx=0, Iyy=0, Izz=0, Rxx=0, Ryy=0, Rzz=0;
Pp.Moments (Ixx, Iyy, Izz);
Pp.RadiusOfGyration (Ixx, Iyy, Izz);
std::cout <<"volume=" << out << std::endl;
std::cout << "CentreOfMass=(" << G.X()<<","<<G.Y()<<","<<G.Z() << ")" << std::endl;
std::cout << "Ixx=" << Ixx << std::endl;
std::cout << "Iyy=" << Iyy << std::endl;
std::cout << "Izz=" << Izz << std::endl;
std::cout << "Rxx=" << Rxx << std::endl;
std::cout << "Ryy=" << Ryy << std::endl;
std::cout << "Rzz=" << Rzz << std::endl;
Viewer vout(50, 50, 500, 500);
vout << box;
vout.StartMessageLoop();
return 0;
}
volume=6
CentreOfMass=(0.5,1,1.5)
Ixx=1.04083
Iyy=0.912871
Izz=0.645497
Rxx=0
Ryy=0
Rzz=0