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

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

Parameters

shape
Type: DigitalRune.Geometry.ShapesShape
The shape.
scale
Type: DigitalRune.Mathematics.AlgebraVector3F
The scale of the shape.
mass
Type: SystemSingle
The target mass. The mass of the computed MassFrame will be equal to this value. Other mass properties are adjusted to match the target mass.
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 .
ArgumentOutOfRangeExceptionmass 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.

Density: Since this method does not use a density value, the Density property of the MassFrame is set to 0.

See Also