TransformedShapeGetVolume Method |
Namespace: DigitalRune.Geometry.Shapes
Exception | Condition |
---|---|
ArgumentOutOfRangeException | relativeError is negative. |
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.