Click or drag to resize
DigitalRuneMassFrameFromShapeAndDensity Method
Computes a mass frame for the given shape and density.

Namespace: DigitalRune.Physics
Assembly: DigitalRune.Physics (in DigitalRune.Physics.dll) Version: 1.10.0.0 (1.10.0.14427)
Syntax
public static MassFrame FromShapeAndDensity(
	Shape shape,
	Vector3F scale,
	float density,
	float relativeDistanceThreshold,
	int iterationLimit
)

Parameters

shape
Type: DigitalRune.Geometry.ShapesShape
The shape.
scale
Type: DigitalRune.Mathematics.AlgebraVector3F
The scale of the shape.
density
Type: SystemSingle
The density.
relativeDistanceThreshold
Type: SystemSingle
The relative distance threshold. If no mass or inertia formula for the given shape are known the shape is approximated with a triangle mesh and the mass frame of this mesh is returned. The relative distance threshold controls the accuracy of the approximated mesh. Good default values are 0.05 to get an approximation with an error of about 5%.
iterationLimit
Type: SystemInt32
The iteration limit. For some shapes the mass properties are computed with an iterative algorithm. No more than iterationLimit iterations will be performed. A value of 3 gives good results in most cases. Use a value of -1 to get only a coarse approximation.

Return Value

Type: MassFrame
A new MassFrame for the given parameters is returned.
Exceptions
ExceptionCondition
ArgumentNullExceptionshape is .
ArgumentOutOfRangeExceptiondensity is negative or 0.
ArgumentOutOfRangeExceptionrelativeDistanceThreshold is negative.
Remarks
Composite shapes: If the given shape is a CompositeShape, the computed mass properties are only correct if the children of the composite shape do not overlap. Overlapping parts are counted twice and so the result will not be correct. If a child of a composite shape is a RigidBody the MassFrame of the rigid body will be used for this child.
See Also