1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
18 #include <GProp_PrincipalProps.hxx>
19 #include <GProp_UndefinedAxis.hxx>
28 GProp_PrincipalProps::GProp_PrincipalProps () {
30 i1= i2 = i3 = RealLast();
31 r1 = r2 = r3 = RealLast();
32 v1 = Vec (1.0, 0.0, 0.0);
33 v2 = Vec (0.0, 1.0, 0.0);
34 v3 = Vec (0.0, 0.0, 1.0);
35 g = Pnt (RealLast(), RealLast(), RealLast());
39 GProp_PrincipalProps::GProp_PrincipalProps (
40 const Standard_Real Ixx, const Standard_Real Iyy, const Standard_Real Izz,
41 const Standard_Real Rxx, const Standard_Real Ryy, const Standard_Real Rzz,
42 const gp_Vec& Vxx, const gp_Vec& Vyy, const gp_Vec& Vzz, const gp_Pnt& G) :
43 i1 (Ixx), i2 (Iyy), i3 (Izz), r1 (Rxx), r2 (Ryy), r3 (Rzz),
44 v1 (Vxx), v2 (Vyy), v3 (Vzz), g (G) { }
47 Standard_Boolean GProp_PrincipalProps::HasSymmetryAxis () const {
49 // Standard_Real Eps1 = Abs(Epsilon (i1));
50 // Standard_Real Eps2 = Abs(Epsilon (i2));
51 const Standard_Real aRelTol = 1.e-10;
52 Standard_Real Eps1 = Abs(i1)*aRelTol;
53 Standard_Real Eps2 = Abs(i2)*aRelTol;
54 return (Abs (i1 - i2) <= Eps1 || Abs (i1 - i3) <= Eps1 ||
55 Abs (i2 - i3) <= Eps2);
58 Standard_Boolean GProp_PrincipalProps::HasSymmetryAxis (const Standard_Real aTol) const {
61 Standard_Real Eps1 = Abs(i1*aTol) + Abs(Epsilon(i1));
62 Standard_Real Eps2 = Abs(i2*aTol) + Abs(Epsilon(i2));
63 return (Abs (i1 - i2) <= Eps1 || Abs (i1 - i3) <= Eps1 ||
64 Abs (i2 - i3) <= Eps2);
68 Standard_Boolean GProp_PrincipalProps::HasSymmetryPoint () const {
70 // Standard_Real Eps1 = Abs(Epsilon (i1));
71 const Standard_Real aRelTol = 1.e-10;
72 Standard_Real Eps1 = Abs(i1)*aRelTol;
73 return (Abs (i1 - i2) <= Eps1 && Abs (i1 - i3) <= Eps1);
76 Standard_Boolean GProp_PrincipalProps::HasSymmetryPoint (const Standard_Real aTol) const {
78 Standard_Real Eps1 = Abs(i1*aTol) + Abs(Epsilon(i1));
79 return (Abs (i1 - i2) <= Eps1 && Abs (i1 - i3) <= Eps1);
83 void GProp_PrincipalProps::Moments (Standard_Real& Ixx, Standard_Real& Iyy, Standard_Real& Izz) const {
91 const Vec& GProp_PrincipalProps::FirstAxisOfInertia () const {return v1;}
94 const Vec& GProp_PrincipalProps::SecondAxisOfInertia () const {return v2;}
97 const Vec& GProp_PrincipalProps::ThirdAxisOfInertia () const {return v3;}
100 void GProp_PrincipalProps::RadiusOfGyration (
101 Standard_Real& Rxx, Standard_Real& Ryy, Standard_Real& Rzz) const {