QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_massprop.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(ON_MASSPROP_INC_)
17#define ON_MASSPROP_INC_
18
19/*
20Description:
21 This class is used to returned results of
22 mass properties calculations.
23*/
25{
26public:
29
30 // Set values to constructor defaults.
31 void Create();
32
33 /*
34 Description:
35 Prints a text description of the mass properties
36 information.
37 Parameters:
38 dump - [in] target for text dump information.
39 */
40 void Dump( ON_TextLog& dump ) const;
41
42
43 /*
44 Description:
45 Sum a list of mass properties together to get
46 an aggregate mass.
47 Parameters:
48 count - [in] number of elements in the summands array.
49 summands - [in] array of mass properties to add
50 bAddTo - [in] if true, then the summands are added to
51 the existing mass.
52 Returns:
53 True if successful.
54 */
55 bool Sum(
56 int count,
57 const ON_MassProperties* summands,
58 bool bAddTo = false
59 );
60
61
62 // Determines what type of "mass" is returned.
63 // 1 = length, 2 = area, 3 = volume
66
67 // These flags are set to true if the calcluation was
68 // successful. If a flag is false, the corresponding
69 // values should not be used.
78
79
80
81 // MASS - length, area, or volume of object
82 // = integral of "dm" over the object
83 double m_mass;
84 double m_mass_err; // uncertainty in calculation
85
86 // CENTROID - in world coordinate system
87 double m_x0; // = m_world_x / m_mass
88 double m_x0_err;
89 double m_y0; // = m_world_y / m_mass
90 double m_y0_err;
91 double m_z0; // = m_world_z / m_mass
92 double m_z0_err;
93
94
95
96
97 // FIRST MOMENTS - with respect to world coordinate system
98 // integral of "x dm" over the length/area/volume
99 double m_world_x;
100 double m_world_x_err; // uncertainty in calculation
101
102 // integral of "y dm" over the length/area/volume
103 double m_world_y;
104 double m_world_y_err; // uncertainty in calculation
105
106 // integral of "z dm" over the length/area/volume
107 double m_world_z;
108 double m_world_z_err; // uncertainty in calculation
109
110 // SECOND MOMENTS - with respect to world coordinate system
111 // integral of "xx dm" over the length/area/volume
113 double m_world_xx_err; // uncertainty in calculation
114 // integral of "yy dm" over the length/area/volume
116 double m_world_yy_err; // uncertainty in calculation
117 // integral of "zz dm" over the length/area/volume
119 double m_world_zz_err; // uncertainty in calculation
120
121 // PRODUCT MOMENTS - with respect to world coordinate system
122 // integral of "xy dm" over the length/area/volume
124 double m_world_xy_err; // uncertainty in calculation
125 // integral of "yz dm" over the length/area/volume
127 double m_world_yz_err; // uncertainty in calculation
128 // integral of "zx dm" over the length/area/volume
130 double m_world_zx_err; // uncertainty in calculation
131
132
133
134
135 // The "centroid coordinate system" (ccs) is the
136 // coordinate system with origin at the centroid and
137 // axes parallel to the world coordinate axes.
138
139 // SECOND MOMENTS - with respect to centroid coordinate system
140 // integral of "xx dm" over the length/area/volume
141 double m_ccs_xx;
142 double m_ccs_xx_err; // uncertainty in calculation
143 // integral of "yy dm" over the length/area/volume
144 double m_ccs_yy;
145 double m_ccs_yy_err; // uncertainty in calculation
146 // integral of "zz dm" over the length/area/volume
147 double m_ccs_zz;
148 double m_ccs_zz_err; // uncertainty in calculation
149
150 // PRODUCT MOMENTS - with respect to centroid coordinate system
151 // integral of "xy dm" over the length/area/volume
152 double m_ccs_xy;
153 double m_ccs_xy_err; // uncertainty in calculation
154 // integral of "yz dm" over the length/area/volume
155 double m_ccs_yz;
156 double m_ccs_yz_err; // uncertainty in calculation
157 // integral of "zx dm" over the length/area/volume
158 double m_ccs_zx;
159 double m_ccs_zx_err; // uncertainty in calculation
160
161
170
171
172 // FUNCTIONAL INTERFACE for those who wish to ignore error terms.
173
174 /*
175 Returns:
176 Centroid of object.
177 */
178 ON_3dPoint Centroid() const;
179
180 /*
181 Description:
182 Returns length of the curve if the mass properties
183 calculation was a length calculation.
184 Returns:
185 Length of the curve if m_mass_type = 1 and zero
186 otherwise.
187 */
188 double Length() const;
189
190 /*
191 Description:
192 Returns area of the surface or mesh if the mass properties
193 calculation was an area calculation.
194 Returns:
195 Area of the surface or mesh if m_mass_type = 2 and zero
196 otherwise.
197 */
198 double Area() const;
199
200 /*
201 Description:
202 Returns volume of the solid if the mass properties
203 calculation was a volume calculation.
204 Returns:
205 Volume of the solid if m_mass_type = 3 and zero
206 otherwise.
207 */
208 double Volume() const;
209
210 /*
211 Description:
212 If m_bValidFirstMoments is true, then the world
213 coordinate first moments are returned in a vector
214 (m_world_x,m_world_y,m_world_z)
215 If m_bValidFirstMoments is false, then (0,0,0) is
216 returned.
217 Returns:
218 First moments with respect to world coordinate system.
219 WorldCoordFirstMoments().x = integral of x dm
220 WorldCoordFirstMoments().y = integral of y dm
221 WorldCoordFirstMoments().z = integral of z dm
222 */
223 ON_3dVector WorldCoordFirstMoments() const;
224
225 /*
226 Description:
227 If m_bValidSecondMoments is true, then the world
228 coordinate second moments are returned in a vector
229 (m_world_xx,m_world_yy,m_world_zz)
230 If m_bValidSecondMoments is false, then (0,0,0) is
231 returned.
232 Returns:
233 Second moments with respect to world coordinate system.
234 WorldCoordSecondMoments().x = integral of x^2 dm
235 WorldCoordSecondMoments().y = integral of y^2 dm
236 WorldCoordSecondMoments().z = integral of z^2 dm
237 See Also:
238 CentroidCoordSecondMoments
239 */
240 ON_3dVector WorldCoordSecondMoments() const;
241
242 /*
243 Description:
244 Calculates the moments of inertia about world
245 coordinate axes.
246 Returns:
247 Moments of inertia with respect to world coordinate system.
248 WorldCoordMomentsOfInertia().x = integral of (y^2 + z^2) dm
249 WorldCoordMomentsOfInertia().y = integral of (z^2 + x^2) dm
250 WorldCoordMomentsOfInertia().z = integral of (z^2 + y^2) dm
251 Remarks:
252 What is meant by "moments of intertia" varies widely in
253 textbooks and papers. The values returned here
254 are the integrals listed in the Returns section.
255 Some applications may want the values from
256 WorldCoordSecondMoments() instead of the values
257 returned here.
258 */
259 ON_3dVector WorldCoordMomentsOfInertia() const;
260
261 /*
262 Description:
263 Calculates the radii of gyration about world
264 coordinate axes.
265 Returns:
266 Radii of gyration with respect to world coordinate system.
267 WorldCoordRadiiOfGyration().x = sqrt(integral of (y^2 + z^2) dm/M)
268 WorldCoordRadiiOfGyration().y = sqrt(integral of (z^2 + x^2) dm/M)
269 WorldCoordRadiiOfGyration().z = sqrt(integral of (z^2 + y^2) dm/M)
270 Remarks:
271 What is meant by "radii of gyration" varies widely in
272 textbooks and papers. The values returned here
273 are the integrals listed in the Returns section.
274 */
275 ON_3dVector WorldCoordRadiiOfGyration() const;
276
277 /*
278 Description:
279 If moments are valid, then the 3x3 inertia matrix with respect
280 to world coordinates is returned. This matrix is sometimes
281 called the "intertia tensor".
282 Parameters:
283 martix - [in] If you want to fill in an existing matrix,
284 pass a pointer to that matrix. Otherwise
285 a matrix will be created and returned.
286 returned.
287 Returns:
288 The inertia matrix or NULL if the moments are not valid.
289
290 m_world_xx m_world_xy m_world_xz
291 m_world_xy m_world_yy m_world_yz
292 m_world_xz m_world_yz m_world_zz
293 See Also:
294 CentroidCoordIntertiaMatrix
295 */
296 ON_Matrix* WorldCoordIntertiaMatrix(
297 ON_Matrix* matrix = NULL
298 ) const;
299
300 /*
301 Description:
302 Calculates the principal moments and principal
303 axes with repect to world coordinates. These are
304 simply the eigenvalues and eigenvectors of the
305 woorld coordinate inertia matrix.
306 Parameters:
307 pxx - [out] principal moment
308 Ax - [out] principal axis for pxx
309 pyy - [out] principal moment
310 Ay - [out] principal axis for pyy
311 pzz - [out] principal moment
312 Az - [out] principal axis for pzz
313 Returns:
314 True if successful.
315 See Also:
316 CentroidCoordPrincipalMoments
317 */
318 bool WorldCoordPrincipalMoments(
319 double* pxx, ON_3dVector& Ax,
320 double* pyy, ON_3dVector& Ay,
321 double* pzz, ON_3dVector& Az
322 ) const;
323
324 /*
325 Description:
326 If m_bValidSecondMoments is true, then the centroid
327 coordinate second moments are returned in a vector
328 (m_ccs_xx,m_ccs_yy,m_ccs_zz)
329 If m_bValidSecondMoments is false, then (0,0,0) is
330 returned.
331 Returns:
332 Second moments with respect to centroid coordinate system.
333 CentroidCoordSecondMoments().x = integral of (x-x0)^2 dm
334 CentroidCoordSecondMoments().y = integral of (y-y0)^2 dm
335 CentroidCoordSecondMoments().z = integral of (z-z0)^2 dm
336 where (x0,y0,z0) = centroid.
337 See Also:
338 WorldCoordSecondMoments
339 */
340 ON_3dVector CentroidCoordSecondMoments() const;
341
342 /*
343 Description:
344 Calculates the moments of inertia about centroid
345 coordinate axes.
346 Returns:
347 Moments of inertia with respect to centroid coordinate system.
348 WorldCoordMomentsOfInertia().x = integral of ((y-y0)^2 + (z-z0)^2) dm
349 WorldCoordMomentsOfInertia().y = integral of ((z-z0)^2 + (x-x0)^2) dm
350 WorldCoordMomentsOfInertia().z = integral of ((z-z0)^2 + (y-y0)^2) dm
351 where (x0,y0,z0) = centroid.
352 Remarks:
353 What is meant by "moments of intertia" varies widely in
354 textbooks and papers. The values returned here
355 are the integrals listed in the Returns section.
356 Some applications may want the values from
357 WorldCoordSecondMoments() instead of the values
358 returned here.
359 */
360 ON_3dVector CentroidCoordMomentsOfInertia() const;
361
362 /*
363 Description:
364 Calculates the radii of gyration about centroid
365 coordinate axes.
366 Returns:
367 Radii of gyration with respect to centroid coordinate system.
368 CentroidCoordRadiiOfGyration().x
369 = sqrt(integral of ((y-y0)^2 + (z-z0)^2) dm/M)
370 CentroidCoordRadiiOfGyration().y
371 = sqrt(integral of ((z-z0)^2 + (x-x0)^2) dm/M)
372 CentroidCoordRadiiOfGyration().z
373 = sqrt(integral of ((z-z0)^2 + (y-y0)^2) dm/M)
374 where (x0,y0,z0) = centroid.
375 Remarks:
376 What is meant by "radii of gyration" varies widely in
377 textbooks and papers. The values returned here
378 are the integrals listed in the Returns section.
379 */
380 ON_3dVector CentroidCoordRadiiOfGyration() const;
381
382 /*
383 Description:
384 If moments are valid, then the 3x3 inertia matrix with respect
385 to centroid coordinates is returned. This matrix is sometimes
386 called the "intertia tensor".
387 Parameters:
388 martix - [in] If you want to fill in an existing matrix,
389 pass a pointer to that matrix. Otherwise
390 a matrix will be created and returned.
391 returned.
392 Returns:
393 The inertia matrix or NULL if the moments are not valid.
394
395 m_ccs_xx m_ccs_xy m_ccs_xz
396 m_ccs_xy m_ccs_yy m_ccs_yz
397 m_ccs_xz m_ccs_yz m_ccs_zz
398 See Also:
399 WorldCoordIntertiaMatrix
400 */
401 ON_Matrix* CentroidCoordIntertiaMatrix(
402 ON_Matrix* matrix = NULL
403 ) const;
404
405 /*
406 Description:
407 Calculates the principal moments and principal
408 axes with repect to centroid coordinates. These are
409 simply the eigenvalues and eigenvectors of the
410 centroid coordinate inertia matrix.
411 Parameters:
412 pxx - [out] principal moment
413 Ax - [out] principal axis for pxx
414 pyy - [out] principal moment
415 Ay - [out] principal axis for pyy
416 pzz - [out] principal moment
417 Az - [out] principal axis for pzz
418 Returns:
419 True if successful.
420 See Also:
421 WorldCoordPrincipalMoments
422 */
423 bool CentroidCoordPrincipalMoments(
424 double* pxx, ON_3dVector& Ax,
425 double* pyy, ON_3dVector& Ay,
426 double* pzz, ON_3dVector& Az
427 ) const;
428
429};
430
431#endif
Definition opennurbs_point.h:403
Definition opennurbs_point.h:931
Definition opennurbs_massprop.h:25
double m__reserved6
Definition opennurbs_massprop.h:167
double m_z0
Definition opennurbs_massprop.h:91
double m_ccs_yz
Definition opennurbs_massprop.h:155
double m_world_zx_err
Definition opennurbs_massprop.h:130
double m__reserved1
Definition opennurbs_massprop.h:162
bool m_bValidMass
Definition opennurbs_massprop.h:70
double m_world_yy_err
Definition opennurbs_massprop.h:116
double m_ccs_zx
Definition opennurbs_massprop.h:158
int m_mass_type
Definition opennurbs_massprop.h:64
double m_world_zz
Definition opennurbs_massprop.h:118
double m_ccs_xy_err
Definition opennurbs_massprop.h:153
double m_world_x
Definition opennurbs_massprop.h:99
double m_ccs_yz_err
Definition opennurbs_massprop.h:156
double m_world_xx
Definition opennurbs_massprop.h:112
double m_mass_err
Definition opennurbs_massprop.h:84
double m_ccs_yy_err
Definition opennurbs_massprop.h:145
bool m__bReserved3
Definition opennurbs_massprop.h:77
double m_world_xy
Definition opennurbs_massprop.h:123
double m_world_z
Definition opennurbs_massprop.h:107
double m_ccs_zz_err
Definition opennurbs_massprop.h:148
double m_world_yz
Definition opennurbs_massprop.h:126
double m_x0
Definition opennurbs_massprop.h:87
double m__reserved3
Definition opennurbs_massprop.h:164
bool m_bValidProductMoments
Definition opennurbs_massprop.h:74
bool m_bValidSecondMoments
Definition opennurbs_massprop.h:73
double m_world_xx_err
Definition opennurbs_massprop.h:113
double m_world_yy
Definition opennurbs_massprop.h:115
double m_ccs_zz
Definition opennurbs_massprop.h:147
double m_ccs_zx_err
Definition opennurbs_massprop.h:159
double m_z0_err
Definition opennurbs_massprop.h:92
double m__reserved5
Definition opennurbs_massprop.h:166
int m__reserved
Definition opennurbs_massprop.h:65
bool m_bValidFirstMoments
Definition opennurbs_massprop.h:72
double m_ccs_yy
Definition opennurbs_massprop.h:144
double m_world_zx
Definition opennurbs_massprop.h:129
double m_mass
Definition opennurbs_massprop.h:83
double m_world_y
Definition opennurbs_massprop.h:103
double m_world_z_err
Definition opennurbs_massprop.h:108
double m_world_yz_err
Definition opennurbs_massprop.h:127
bool m__bReserved2
Definition opennurbs_massprop.h:76
double m_world_y_err
Definition opennurbs_massprop.h:104
double m_world_x_err
Definition opennurbs_massprop.h:100
double m_world_xy_err
Definition opennurbs_massprop.h:124
double m_y0_err
Definition opennurbs_massprop.h:90
double m__reserved7
Definition opennurbs_massprop.h:168
double m_ccs_xy
Definition opennurbs_massprop.h:152
double m_y0
Definition opennurbs_massprop.h:89
double m_x0_err
Definition opennurbs_massprop.h:88
double m__reserved4
Definition opennurbs_massprop.h:165
double m_world_zz_err
Definition opennurbs_massprop.h:119
bool m__bReserved1
Definition opennurbs_massprop.h:75
bool m_bValidCentroid
Definition opennurbs_massprop.h:71
double m__reserved2
Definition opennurbs_massprop.h:163
double m__reserved8
Definition opennurbs_massprop.h:169
double m_ccs_xx_err
Definition opennurbs_massprop.h:142
double m_ccs_xx
Definition opennurbs_massprop.h:141
Definition opennurbs_matrix.h:22
Definition opennurbs_textlog.h:20
#define ON_CLASS
Definition opennurbs_defines.h:91
#define NULL
Definition opennurbs_system.h:256