# calc program - Mass Property Calculations

This page describes the calc program, an Alpha_1 utility for calculating surface area and mass properties for a surface or set of surfaces assumed to represent a closed volume.

## Description of the Algorithm

The algorithm for calculating solid polyhedron measures (mass properties) is taken from a paper by A. M. Messner and G. Q. Taylor published in ACM Transactions on Mathematical Software, Vol. 6, No. 1, March 1980, pp. 121--130. For this discussion, the properties of concern will be mass, volume, center of gravity, and moments of inertia.

The above mass property calculations are defined as volume integrals of a given function over a closed region. The algorithm to compute these values when a boundary representation is used, is simply is to convert these volume integrals to surface integrals, using the divergence theorem, and then to approximately calculate the surface integrals using a quadrature rule.

To compute the continuous surface integral over the bounding surface, two different quadrature rules are used, depending on the input data. The first rule, used for piecewise linear surfaces, is a four point quadrature rule defined over a triangle. This means the continuous integral over a triangular region is computed as a discrete sum which is exact for polynomials up to degree three (cubic). This is both sufficient and necessary if moments of inertia are desired. Arbitrary polygons with one or more contours (concave or convex) are split into triangular components with a normal computed for each triangle (to insure that concave sections yield negative results). The calculations are then accumulated for the entire surface by summing up the calculations for all the triangles. The second rule is a 12 point rule which is exact for polynomial equations of degree 7 or less. This rule will calculate the mass properties identified above exactly for a volume bounded by bilinear surfaces. The 12 point rule is again sufficient and necessary to compute the moments of inertia exactly (up to round-off).

The two quadrature rules provide a number of strategies for computing the mass properties of a volume bounded by non-uniform rational B-splines. The first quadrature rule provides an algorithm that computes the exact mass properties for an arbitrary polyhedral volume. Surfaces may be subdivided into a polygonal representation and then the mass properties of the polyhedral volume can be calculated exactly. Empirical evidence shows that the convergence rate for the linear approximation in this case is rather slow, however. The second option is to operate on surfaces directly. The calc program has the ability to subdivide surfaces to an acceptable level and then to approximate them with a bilinear surface and calculate the mass properties using the second quadrature rule. This produces better results using less data. The subdivision is done depth first to eliminate high memory usage. A combination of surfaces and polygons is also acceptable, provided the set of objects bounds some volume. Such cases can arise when processing the results of a boolean combination of volumes bounded by B-splines (see Solid Modeling.)

## Running the calc Program

The calc program recognizes srf_objects, polygons, and transformations in the input stream and ignores everything else. The input stream is assumed to represent one closed volume that is bounded by the surfaces and/or polygons provided. The calc program follows the standard Alpha_1 convention that the normal points into the volume that is bounded. All surfaces and/or polygons in the input must be consistently oriented. A calc.flip flag exists (see below) for data that is consistently oriented the wrong way. Any transformations found in the input stream will be used to map the input objects and will affect the results. Viewing transformations will act as object transformations, if included, and will probably not produce the intended results.

The calc program produces textual output describing the results and the input and puts it on standard out. The number of surfaces and polygons used for the calculations are reported, along with the surface area, volume, mass, center of gravity (x,y,z), and the moments of inertia about the three axes that are calculated. A moment of inertia can also be calculated about an arbitrary axis (see below). Diagnostics are printed when degenerate (zero area) polygons are detected or degenerate objects (zero mass) are detected. Degenerate polygons are ignored, but degenerate objects cause program termination.

Usage:

calc files
Output
textfile The calculated mass properties are reported.
files
objectstream The geometric data for which mass properties are to be computed.
The switches for calc are described below. Values can be set either on the command line or in a state file.
calc.axis
If set, defines an arbitrary axis to use for a moment of inertia. The default is 0,0,1 .
calc.density
Set the density of the material. The default is 1.0 .
calc.flip
If on (the default), reverse the normal orientation of all the input.
calc.origin
If set, defines the origin for the arbitrary axis. The default is (0,0,0).
calc.arbaxis
If set, use an arbitrary axis specified by calc.axis . The default is off.
calc.objresolution
The resolution to use in subdivision if none is specified on the individual surfaces. Default is 0.1 .
If an arbitrary axis is specified, a fourth moment of inertia is computed about that axis. If only a direction is specified with the calc.axis switch, then the axis is assumed to pass through the origin. If an origin is given with the calc.origin switch, the axis used will pass through the given point in the given direction.

## Units

The units in calc come from the part model input and the density specified in the calc.density option.
• The length units are those that the part is modeled in.
• The mass units are based on the density.
• The user must assure that the density is input in units of mass per length cubed, consistant with the length units used in the part.
• The moments of inertia are mass moments and are in units of mass-length squared based on the part length units and the density mass unit.
For example, if the length units of the part are in mm, then the density must be input in mass/mm^3. If you further chose kg as your mass unit, the density is input as kg/mm^3, the mass output is in kg, and the moments of inertia are in kg-mm^2.

## Accuracy

The obj_resolution attribute that is attached to surfaces is what affects the accuracy of the calculations when surfaces are involved. This resolution is specified in absolute object space units. This means that a surface that is 300 units long with a resolution of 1 will be subdivided until it is "flat" to within 1 unit. This applies to the srf_mash program and the calc program when surfaces are provided as input. The srf_mash program retains the resulting triangles on internal lists until finished, although it does the subdivision depth first, as calc does, which prevents very low resolutions to be used (very large memory requirements result). If the calc program is used to do the subdivisions, however; the intermediate surfaces are thrown out as they become unnecessary, and the program maintains a small operating size. This means calculations can be performed with the resolution set very low, although much computing time is required. It is best to start with a large resolution and decrease it as necessary.