7fd59977 |
1 | -- File: GProps.cdl<3> |
2 | -- Created: Mon Aug 24 18:10:07 1992 |
3 | -- Author: Michel CHAUVAT |
4 | -- JCV January 1992 |
5 | ---Copyright: Matra Datavision 1992 |
6 | |
7 | |
8 | class GProps from GProp |
9 | |
10 | --- Purpose : |
11 | -- Implements a general mechanism to compute the global properties of |
12 | -- a "compound geometric system" in 3d space by composition of the |
13 | -- global properties of "elementary geometric entities" such as |
14 | -- (curve, surface, solid, set of points). It is possible to compose |
15 | -- the properties of several "compound geometric systems" too. |
16 | -- |
17 | -- To computes the global properties of a compound geometric |
18 | -- system you should : |
19 | -- . declare the GProps using a constructor which initializes the |
20 | -- GProps and defines the location point used to compute the inertia |
21 | -- . compose the global properties of your geometric components with |
22 | -- the properties of your system using the method Add. |
23 | -- |
24 | -- To compute the global properties of the geometric components of |
25 | -- the system you should use the services of the following classes : |
26 | -- - class PGProps for a set of points, |
27 | -- - class CGProps for a curve, |
28 | -- - class SGProps for a surface, |
29 | -- - class VGProps for a "solid". |
30 | -- The classes CGProps, SGProps, VGProps are generic classes and |
31 | -- must be instantiated for your application. |
32 | -- |
33 | -- |
34 | -- The global properties computed are : |
35 | -- - the dimension (length, area or volume) |
36 | -- - the mass, |
37 | -- - the centre of mass, |
38 | -- - the moments of inertia (static moments and quadratic moments), |
39 | -- - the moment about an axis, |
40 | -- - the radius of gyration about an axis, |
41 | -- - the principal properties of inertia : |
42 | -- (sea also class PrincipalProps) |
43 | -- . the principal moments, |
44 | -- . the principal axis of inertia, |
45 | -- . the principal radius of gyration, |
46 | -- |
47 | -- |
48 | -- |
49 | -- Example of utilisation in a simplified C++ implementation : |
50 | -- |
51 | -- //declares the GProps, the point (0.0, 0.0, 0.0) of the |
52 | -- //absolute cartesian coordinate system is used as |
53 | -- //default reference point to compute the centre of mass |
54 | -- GProp_GProps System (); |
55 | -- |
56 | -- //computes the inertia of a 3d curve |
57 | -- Your_CGProps Component1 (curve, ....); |
58 | -- |
59 | -- //computes the inertia of surfaces |
60 | -- Your_SGprops Component2 (surface1, ....); |
61 | -- Your_SGprops Component3 (surface2,....); |
62 | -- |
63 | -- //composes the global properties of components 1, 2, 3 |
64 | -- //a density can be associated with the components, the |
65 | -- //density can be defaulted to 1. |
66 | -- Real Density1 = 2.0; |
67 | -- Real Density2 = 3.0; |
68 | -- System.Add (Component1, Density1); |
69 | -- System.Add (Component2, Density2); |
70 | -- System.Add (Component3); |
71 | -- |
72 | -- //returns the centre of mass of the system in the |
73 | -- //absolute cartesian coordinate system |
74 | -- gp_Pnt G = System.CentreOfMass (); |
75 | -- |
76 | -- //computes the principales inertia of the system |
77 | -- GProp_PrincipalProps Pp = System.PrincipalProperties(); |
78 | -- |
79 | -- //returns the principal moments and radius of gyration |
80 | -- Real Ixx, Iyy, Izz, Rxx, Ryy, Rzz; |
81 | -- Pp.Moments (Ixx, Iyy, Izz); |
82 | -- Pp.RadiusOfGyration (Ixx, Iyy, Izz); |
83 | -- |
84 | -- |
85 | |
86 | uses Ax1 from gp, |
87 | Mat from gp, |
88 | Pnt from gp, |
89 | PrincipalProps from GProp |
90 | |
91 | raises DomainError from Standard |
92 | |
93 | is |
94 | |
95 | Create returns GProps; |
96 | --- Purpose : |
97 | -- The origin (0, 0, 0) of the absolute cartesian coordinate system |
98 | -- is used to compute the global properties. |
99 | |
100 | |
101 | Create (SystemLocation : Pnt) returns GProps; |
102 | --- Purpose : |
103 | -- The point SystemLocation is used to compute the gobal properties |
104 | -- of the system. For more accuracy it is better to define this |
105 | -- point closed to the location of the system. For example it could |
106 | -- be a point around the centre of mass of the system. |
107 | -- This point is referred to as the reference point for |
108 | -- this framework. For greater accuracy it is better for |
109 | -- the reference point to be close to the location of the |
110 | -- system. It can, for example, be a point near the |
111 | -- center of mass of the system. |
112 | -- At initialization, the framework is empty; i.e. it |
113 | -- retains no dimensional information such as mass, or |
114 | -- inertia. However, it is now able to bring together |
115 | -- global properties of various other systems, whose |
116 | -- global properties have already been computed |
117 | -- using another framework. To do this, use the |
118 | -- function Add to define the components of the |
119 | -- system. Use it once per component of the system, |
120 | -- and then use the interrogation functions available to |
121 | -- access the computed values. |
122 | |
123 | |
124 | Add (me : in out; Item : GProps; Density : Real =1.0) |
125 | --- Purpose : Either |
126 | -- - initializes the global properties retained by this |
127 | -- framework from those retained by the framework Item, or |
128 | -- - brings together the global properties still retained by |
129 | -- this framework with those retained by the framework Item. |
130 | -- The value Density, which is 1.0 by default, is used as |
131 | -- the density of the system analysed by Item. |
132 | -- Sometimes the density will have already been given at |
133 | -- the time of construction of the framework Item. This |
134 | -- may be the case for example, if Item is a |
135 | -- GProp_PGProps framework built to compute the |
136 | -- global properties of a set of points ; or another |
137 | -- GProp_GProps object which already retains |
138 | -- composite global properties. In these cases the real |
139 | -- density was perhaps already taken into account at the |
140 | -- time of construction of Item. Note that this is not |
141 | -- checked: if the density of parts of the system is taken |
142 | -- into account two or more times, results of the |
143 | -- computation will be false. |
144 | -- Notes : |
145 | -- - The point relative to which the inertia of Item is |
146 | -- computed (i.e. the reference point of Item) may be |
147 | -- different from the reference point in this |
148 | -- framework. Huygens' theorem is applied |
149 | -- automatically to transfer inertia values to the |
150 | -- reference point in this framework. |
151 | -- - The function Add is used once per component of |
152 | -- the system. After that, you use the interrogation |
153 | -- functions available to access values computed for the system. |
154 | -- - The system whose global properties are already |
155 | -- brought together by this framework is referred to |
156 | -- as the current system. However, the current system |
157 | -- is not retained by this framework, which maintains |
158 | -- only its global properties. |
159 | -- Exceptions |
160 | -- Standard_DomainError if Density is less than or |
161 | -- equal to gp::Resolution(). |
162 | raises DomainError |
163 | is static; |
164 | |
165 | |
166 | |
167 | Mass (me) returns Real is static; |
168 | --- Purpose: Returns the mass of the current system. |
169 | -- If no density is attached to the components of the |
170 | -- current system the returned value corresponds to : |
171 | -- - the total length of the edges of the current |
172 | -- system if this framework retains only linear |
173 | -- properties, as is the case for example, when |
174 | -- using only the LinearProperties function to |
175 | -- combine properties of lines from shapes, or |
176 | -- - the total area of the faces of the current system if |
177 | -- this framework retains only surface properties, |
178 | -- as is the case for example, when using only the |
179 | -- SurfaceProperties function to combine |
180 | -- properties of surfaces from shapes, or |
181 | -- - the total volume of the solids of the current |
182 | -- system if this framework retains only volume |
183 | -- properties, as is the case for example, when |
184 | -- using only the VolumeProperties function to |
185 | -- combine properties of volumes from solids. |
186 | -- Warning |
187 | -- A length, an area, or a volume is computed in the |
188 | -- current data unit system. The mass of a single |
189 | -- object is obtained by multiplying its length, its area |
190 | -- or its volume by the given density. You must be |
191 | -- consistent with respect to the units used. |
192 | |
193 | |
194 | CentreOfMass (me) returns Pnt is static; |
195 | --- Purpose : |
196 | -- Returns the center of mass of the current system. If |
197 | -- the gravitational field is uniform, it is the center of gravity. |
198 | -- The coordinates returned for the center of mass are |
199 | -- expressed in the absolute Cartesian coordinate system. |
200 | |
201 | MatrixOfInertia (me) returns Mat is static; |
202 | --- Purpose: |
203 | -- returns the matrix of inertia. It is a symmetrical matrix. |
204 | -- The coefficients of the matrix are the quadratic moments of |
205 | -- inertia. |
206 | -- |
207 | -- | Ixx Ixy Ixz | |
208 | -- matrix = | Ixy Iyy Iyz | |
209 | -- | Ixz Iyz Izz | |
210 | -- |
211 | -- The moments of inertia are denoted by Ixx, Iyy, Izz. |
212 | -- The products of inertia are denoted by Ixy, Ixz, Iyz. |
213 | -- The matrix of inertia is returned in the central coordinate |
214 | -- system (G, Gx, Gy, Gz) where G is the centre of mass of the |
215 | -- system and Gx, Gy, Gz the directions parallel to the X(1,0,0) |
216 | -- Y(0,1,0) Z(0,0,1) directions of the absolute cartesian |
217 | -- coordinate system. It is possible to compute the matrix of |
218 | -- inertia at another location point using the Huyghens theorem |
219 | -- (you can use the method of package GProp : HOperator). |
220 | |
221 | |
222 | StaticMoments (me; Ix, Iy, Iz : out Real) is static; |
223 | --- Purpose : Returns Ix, Iy, Iz, the static moments of inertia of the |
224 | -- current system; i.e. the moments of inertia about the |
225 | -- three axes of the Cartesian coordinate system. |
226 | |
227 | |
228 | |
229 | MomentOfInertia (me; A : Ax1) returns Real is static; |
230 | --- Purpose : |
231 | -- computes the moment of inertia of the material system about the |
232 | -- axis A. |
233 | |
234 | |
235 | PrincipalProperties (me) returns PrincipalProps is static; |
236 | --- Purpose : Computes the principal properties of inertia of the current system. |
237 | -- There is always a set of axes for which the products |
238 | -- of inertia of a geometric system are equal to 0; i.e. the |
239 | -- matrix of inertia of the system is diagonal. These axes |
240 | -- are the principal axes of inertia. Their origin is |
241 | -- coincident with the center of mass of the system. The |
242 | -- associated moments are called the principal moments of inertia. |
243 | -- This function computes the eigen values and the |
244 | -- eigen vectors of the matrix of inertia of the system. |
245 | -- Results are stored by using a presentation framework |
246 | -- of principal properties of inertia |
247 | -- (GProp_PrincipalProps object) which may be |
248 | -- queried to access the value sought. |
249 | |
250 | |
251 | |
252 | RadiusOfGyration (me; A : Ax1) returns Real is static; |
253 | --- Purpose : Returns the radius of gyration of the current system about the axis A. |
254 | |
255 | |
256 | |
257 | |
258 | fields |
259 | |
260 | g : Pnt is protected; |
261 | --- Purpose : centre of mass |
262 | loc : Pnt is protected; |
263 | --- Purpose : location point used to compute the inertia |
264 | dim : Real is protected; |
265 | --- Purpose : mass or length or area or volume of the GProps |
266 | inertia : Mat is protected; |
267 | --- Purpose : matrix of inertia |
268 | |
269 | end GProps; |
270 | |
271 | |