Click or drag to resize
DigitalRuneTransformedShapeGetVolume Method
Gets the volume of this shape.

Namespace: DigitalRune.Geometry.Shapes
Assembly: DigitalRune.Geometry (in DigitalRune.Geometry.dll) Version: 1.18.0.0 (1.18.2.14427)
Syntax
public override float GetVolume(
	float relativeError,
	int iterationLimit
)

Parameters

relativeError
Type: SystemSingle
The desired relative error for approximations (in the range [0, 1]). For example, use the value 0.01 to get a maximal error of about 1%.
iterationLimit
Type: SystemInt32
The iteration limit. Must be greater than or equal to 0. For most cases a small value like 4 is appropriate.

Return Value

Type: Single
The volume of this shape.
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionrelativeError is negative.
Remarks

If the volume can be computed with an exact formula, then the exact volume is returned. But for some shapes an approximate volume is computed. For approximated volumes relativeError defines the desired relative error and if the volume is computed by an iterative algorithm, no more than iterationLimit iterations are performed. If the iterationLimit is reached first, the returned mesh will have a higher relative error.

Currently, relativeError is proportional to the error of the approximated volume. But it is not guaranteed that the relative error between the approximated volume and the exact volume is less than relativeError. It is only guaranteed that a smaller relativeError value leads to a more accurate approximation.

Remember: To compute the volume of a scaled shape, you can compute the volume of the unscaled shape and multiply the result with the scaling factors:

volumescaled = volumeunscaled * scaleX * scaleY * scaleZ

Notes to Inheritors: The base implementation of this method computes the volume from the mesh of the shape (see GetMesh(Single, Int32)). And if iterationLimit is 0, the volume of the axis-aligned bounding box (see GetAabb(Pose)) is used. Derived classes should override this method to compute a more accurate volume or to provide a faster implementation.

See Also