hmi.physics
Class Mass

java.lang.Object
  extended by hmi.physics.Mass
Direct Known Subclasses:
OdeMass

public abstract class Mass
extends Object


Constructor Summary
Mass()
           
 
Method Summary
 void addMass(Mass m, float[] p1, float[] p2, float[] newPos)
          Combines with another Mass object.
abstract  void adjustMass(float newMass)
          Adjust the mass to be newMass (in kg)
abstract  Mass copy()
           
abstract  void getCOM(float[] c)
          Get the center of mass
abstract  void getInertiaTensor(float[] I)
          Get the inertia tensor
abstract  float getMass()
          Get the mass (in kg)
abstract  void rotate(float[] q)
          Rotates the inertia tensor
 void scale(float s)
          Uniform scale Assumes that the Mass objects has it COM at (0,0,0) and that the density is uniform.
 void scale(float[] s)
          Non-uniform scale Assumes that the Mass objects has it COM at (0,0,0) and that the density is uniform.
abstract  void setCOM(float[] c)
          Sets the center of mass
abstract  void setFromBox(float[] size, float density)
          Set a new box mass, assumes center at (0,0,0)
abstract  void setFromCapsule(float radius, float height, int direction, float density)
          Set a capsule mass, assume center = CoM at (0,0,0)
abstract  void setFromGMesh(GMesh m, float density)
          Set mass properties on the basis of a closed GMesh, assumes uniform density density is set in kg/m3 (or mass unit/length unit^3)
abstract  void setFromSphere(float radius, float density)
          Set a sphere-shaped mass, assume center at (0,0,0)
abstract  void setInertiaTensor(float[] I)
          Sets the inertia tensor
abstract  String toString()
          String representation
 void translate(float[] pos)
           
abstract  void translate(float x, float y, float z)
          Translates the COM and inertia tensor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Mass

public Mass()
Method Detail

getCOM

public abstract void getCOM(float[] c)
Get the center of mass


getInertiaTensor

public abstract void getInertiaTensor(float[] I)
Get the inertia tensor


setCOM

public abstract void setCOM(float[] c)
Sets the center of mass


setInertiaTensor

public abstract void setInertiaTensor(float[] I)
Sets the inertia tensor


getMass

public abstract float getMass()
Get the mass (in kg)

Returns:
the mass

adjustMass

public abstract void adjustMass(float newMass)
Adjust the mass to be newMass (in kg)

Parameters:
newMass - the new mass

translate

public abstract void translate(float x,
                               float y,
                               float z)
Translates the COM and inertia tensor


translate

public void translate(float[] pos)

rotate

public abstract void rotate(float[] q)
Rotates the inertia tensor

Parameters:
q - rotation as quaternion

setFromBox

public abstract void setFromBox(float[] size,
                                float density)
Set a new box mass, assumes center at (0,0,0)

Parameters:
size - of the sides of the box
density - the density of the box

setFromSphere

public abstract void setFromSphere(float radius,
                                   float density)
Set a sphere-shaped mass, assume center at (0,0,0)

Parameters:
radius - radius of the sphere
density - density of the sphere

setFromCapsule

public abstract void setFromCapsule(float radius,
                                    float height,
                                    int direction,
                                    float density)
Set a capsule mass, assume center = CoM at (0,0,0)

Parameters:
radius - radius of the spheres and cylinder
height - height of the cylinder
direction - direction of the long axes of the cylinder: 1=x, 2=y, 3=z
density - density

setFromGMesh

public abstract void setFromGMesh(GMesh m,
                                  float density)
Set mass properties on the basis of a closed GMesh, assumes uniform density density is set in kg/m3 (or mass unit/length unit^3)


toString

public abstract String toString()
String representation

Overrides:
toString in class Object

copy

public abstract Mass copy()

scale

public void scale(float[] s)
Non-uniform scale Assumes that the Mass objects has it COM at (0,0,0) and that the density is uniform.

Parameters:
s - scale vector [sx,sy,sz]

scale

public void scale(float s)
Uniform scale Assumes that the Mass objects has it COM at (0,0,0) and that the density is uniform.

Parameters:
s - the desired acale

addMass

public void addMass(Mass m,
                    float[] p1,
                    float[] p2,
                    float[] newPos)
Combines with another Mass object. Assumes that both Mass objects have their local COM at (0,0,0) p1 and p2 indicated the COM of this Mass object and the Mass object to add in world coordinates The new position of the COM in world coordinates is returned in newPos This Mass object will be translated so that its local center is again at (0,0,0)

Parameters:
m - mass to add
p1 - position of this mass object in world coordinates
p2 - position of m in world coordinates
newPos - output: new COM in world coordinates of the combined mass, cannot be aliased to p1 or p2