MassFrame Class |
Namespace: DigitalRune.Physics
The MassFrame type exposes the following members.
Name | Description | |
---|---|---|
Adjust |
Changes the mass so that it is equal to the given target mass and the related properties
(inertia) are scaled accordingly.
| |
Clone |
Creates a new MassFrame that is a clone (deep copy) of the current instance.
| |
Equals | (Inherited from Object.) | |
FromShapeAndDensity |
Computes a mass frame for the given shape and density.
| |
FromShapeAndMass |
Computes a mass frame for the given shape and target mass.
| |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
Density |
Gets or sets the density.
| |
Inertia |
Gets or sets the inertia.
| |
Mass |
Gets or sets the mass.
| |
MassLimit |
Gets or sets the mass limit. Mass values above this value are treated as infinite.
| |
Pose |
Gets or sets the pose that defines the center of mass and the principal axes.
|
A simplified explanation of mass: Mass defines how difficult it is to change the linear velocity of a body. For example, if mass is infinite it is impossible to move a resting body or to stop a body that is already in motion. The Inertia matrix is the rotational equivalent of Mass. It defines how difficult it is to change the angular velocity of a body.
Center of Mass: For the simulation the center of mass is the center of a rigid body. The center of mass has a special importance because if forces act on an unconstrained rigid body (e.g. a body floating in space) any rotations will be around the center of mass. In contrast, the local space origin of a rigid body can be anywhere where the user wants it to be. For example, the origin of rigid body with a ConeShape is at the base of the cone whereas the center of mass of a cone is inside the cone. Or the origin of a human can be at the feet and the center of mass is above the pelvis area. This allows easy placement of the rigid body in a game editor. Pose. Position defines the position of the center of mass relative to the local space of the rigid body.
Inertia Tensor: The inertia tensor describes the "rotational mass" of a rigid body. In general, the inertia tensor is 3 x 3 matrix. But for all rigid bodies a rotated coordinate space can be found where all off-diagonal elements of the inertia matrix are 0. The axes of this rotated coordinate space are called the "principal axes". Inertia stores the diagonal elements of the diagonalized inertia matrix. And Pose.Orientation stores the orientation of the principal axis space relative to the local space of the rigid body.
Pose: As described above, Pose stores the position of the center of mass and the orientation of the coordinate space where the inertia tensor is a diagonal matrix. In other words, the pose describe the transformation from a space, where the center of mass is at the origin and the inertia matrix is a diagonal matrix, to the local space of the body. In other words, the pose position is equal to the center of mass and the columns of the pose orientation are the principal axes.
Creating new MassFrame instances: You can define Mass, Inertia and Pose manually but this is non-trivial for complex shapes. Therefore, is much simpler to use FromShapeAndDensity(Shape, Vector3F, Single, Single, Int32) or FromShapeAndMass(Shape, Vector3F, Single, Single, Int32) to create a MassFrame instance. The first method takes a shape and a density and computes the mass properties. The second method takes a shape and a target mass value and computes mass frame properties so that the mass is equal to the target mass.
Composite Objects: In some cases a rigid body consists of parts with different densities, for example: A hammer has a metal head and a wooden shaft. To model these kind of objects you can create a rigid body with a CompositeShape. Normally, all child object in the CompositeShape have the same density - but: If the child of a CompositeShape is a RigidBody, the mass properties of this child rigid body are used. Remember: The children of a CompositeShape are of the type IGeometricObject and a RigidBody implements IGeometricObject. Therefore, a RigidBody can be the child of a CompositeShape.
Now, to model a hammer: Create a rigid body for the metal head. Create a rigid body for the wooden shaft. Add both rigid bodies to a CompositeShape. Call FromShapeAndDensity(Shape, Vector3F, Single, Single, Int32) to compute a MassFrame instance. Then you can create the rigid body "hammer" where the shape is the CompositeShape and the MassFrame is the computed mass frame instance. The first two bodies are only used to define the composite shape - they are never added to the simulation directly.
Whenever FromShapeAndDensity(Shape, Vector3F, Single, Single, Int32) or FromShapeAndMass(Shape, Vector3F, Single, Single, Int32) are called for composite shapes, they check if a child shape is a rigid body. And if a child is a rigid body the MassFrame of this child rigid body is used directly for this child.