summaryrefslogtreecommitdiff
path: root/src/GProp/GProp_PrincipalProps.cxx
blob: 822cec9be4c49c571cbf2026580673b505bf78ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <GProp_PrincipalProps.ixx>


typedef gp_Vec Vec;
typedef gp_Pnt Pnt;





   GProp_PrincipalProps::GProp_PrincipalProps () {

      i1= i2 = i3 = RealLast();
      r1 = r2 = r3 = RealLast();
      v1 = Vec (1.0, 0.0, 0.0);
      v2 = Vec (0.0, 1.0, 0.0);
      v3 = Vec (0.0, 0.0, 1.0);
      g = Pnt (RealLast(), RealLast(), RealLast());
   }


   GProp_PrincipalProps::GProp_PrincipalProps (
   const Standard_Real Ixx, const Standard_Real Iyy, const Standard_Real Izz, 
   const Standard_Real Rxx, const Standard_Real Ryy, const Standard_Real Rzz,
   const gp_Vec& Vxx, const gp_Vec& Vyy, const gp_Vec& Vzz, const gp_Pnt& G) :
   i1 (Ixx), i2 (Iyy), i3 (Izz), r1 (Rxx), r2 (Ryy), r3 (Rzz),
   v1 (Vxx), v2 (Vyy), v3 (Vzz), g (G) { }


   Standard_Boolean GProp_PrincipalProps::HasSymmetryAxis () const {

//     Standard_Real Eps1 = Abs(Epsilon (i1));
//     Standard_Real Eps2 = Abs(Epsilon (i2));
     const Standard_Real aRelTol = 1.e-10;
     Standard_Real Eps1 = Abs(i1)*aRelTol;
     Standard_Real Eps2 = Abs(i2)*aRelTol;
     return (Abs (i1 - i2) <= Eps1 || Abs (i1 - i3) <= Eps1 ||
             Abs (i2 - i3) <= Eps2);
   }

   Standard_Boolean GProp_PrincipalProps::HasSymmetryAxis (const Standard_Real aTol) const {


     Standard_Real Eps1 = Abs(i1*aTol) + Abs(Epsilon(i1));
     Standard_Real Eps2 = Abs(i2*aTol) + Abs(Epsilon(i2));
     return (Abs (i1 - i2) <= Eps1 || Abs (i1 - i3) <= Eps1 ||
             Abs (i2 - i3) <= Eps2);
   }


   Standard_Boolean GProp_PrincipalProps::HasSymmetryPoint () const {

//     Standard_Real Eps1 = Abs(Epsilon (i1));
     const Standard_Real aRelTol = 1.e-10;
     Standard_Real Eps1 = Abs(i1)*aRelTol;
     return (Abs (i1 - i2) <= Eps1 && Abs (i1 - i3) <= Eps1);
   }

   Standard_Boolean GProp_PrincipalProps::HasSymmetryPoint (const Standard_Real aTol) const {

     Standard_Real Eps1 = Abs(i1*aTol) + Abs(Epsilon(i1));
     return (Abs (i1 - i2) <= Eps1 && Abs (i1 - i3) <= Eps1);
   }


   void GProp_PrincipalProps::Moments (Standard_Real& Ixx, Standard_Real& Iyy, Standard_Real& Izz) const {

      Ixx = i1;
      Iyy = i2;
      Izz = i3;
   }


   const Vec& GProp_PrincipalProps::FirstAxisOfInertia () const {return  v1;}


   const Vec& GProp_PrincipalProps::SecondAxisOfInertia () const {return  v2;}


   const Vec& GProp_PrincipalProps::ThirdAxisOfInertia () const {return v3;}


   void GProp_PrincipalProps::RadiusOfGyration (
   Standard_Real& Rxx, Standard_Real& Ryy, Standard_Real& Rzz) const {
   
     Rxx = r1;
     Ryy = r2;
     Rzz = r3;
   }