| Package | org.generalrelativity.foam.dynamics.element.body |
| Class | public class RigidBody |
| Inheritance | RigidBody SimpleParticle |
| Implements | IBody, IODE, ISimulatable |
| Subclasses | Circle, CubicBezierCurve |
| Property | Defined by | ||
|---|---|---|---|
| av : Number | RigidBody | ||
| collisionTypeID : String [read-only]
| RigidBody | ||
| edges : Array [read-only]
| RigidBody | ||
![]() | elasticity : Number | SimpleParticle | |
![]() | force : Vector | SimpleParticle | |
![]() | friction : Number | SimpleParticle | |
| I : Number [read-only]
| RigidBody | ||
| inverseI : Number [read-only]
| RigidBody | ||
![]() | inverseMass : Number | SimpleParticle | |
![]() | mass : Number | SimpleParticle | |
![]() | position : Vector | SimpleParticle | |
| q : Number | RigidBody | ||
| rotation : RotationMatrix
[read-only]
Gets the rotation matrix of the body
Because the creation of a rotation matrix involves 2 trigonometric function calls, it's worthwhile to do a check to see if we need to create a new rotation matrix. | RigidBody | ||
![]() | state : Array
Gets the state of the differential equation
Consider a particle with position x and velocity v. | SimpleParticle | |
| torque : Number [read-only]
| RigidBody | ||
![]() | velocity : Vector | SimpleParticle | |
| vertices : Array [read-only]
| RigidBody | ||
![]() | vx : Number | SimpleParticle | |
![]() | vy : Number | SimpleParticle | |
![]() | x : Number
Note that these values that constitute this IODE's state use getters/setters
that access specific indices within _state.
| SimpleParticle | |
![]() | y : Number | SimpleParticle | |
| Property | Defined by | ||
|---|---|---|---|
| _edges : Array body edges
| RigidBody | ||
![]() | _elasticity : Number elastic coefficient of particle (used in collision response)
| SimpleParticle | |
![]() | _force : Vector
holds all accummulate forces
| SimpleParticle | |
![]() | _friction : Number frictional coefficient (used in collision response)
| SimpleParticle | |
![]() | _generators : Array holds all IForceGenerators affecting this particle
| SimpleParticle | |
| _I : Number inertia tensor
| RigidBody | ||
| _inverseI : Number inverse inertia tensor
| RigidBody | ||
![]() | _inverseMass : Number holds the inverse mass- this is an optimization as multiplication is faster than division and we can calculate this offline
| SimpleParticle | |
![]() | _mass : Number holds the mass of the particle
| SimpleParticle | |
| _rotation : RotationMatrix
rotation matrix of body
| RigidBody | ||
![]() | _state : Array holds the state of the system
| SimpleParticle | |
| _torque : Number torque accumulator
| RigidBody | ||
| _vertices : Array body vertices
| RigidBody | ||
| Method | Defined by | ||
|---|---|---|---|
|
RigidBody(x:Number, y:Number, mass:Number = 100, vertices:Array = null, vx:Number = 0, vy:Number = 0, friction:Number = 0.2, elasticity:Number = 0.25, q:Number = 0, av:Number = 0)
Creates a new RigidBody
This will most likely be the most used element in FOAM. | RigidBody | ||
![]() |
accumulateForces():void
Accumulates forces
| SimpleParticle | |
![]() |
Adds a force to the particle
| SimpleParticle | |
|
Adds a force at a specific point on the body
IF the point specified is not the center of mass (0,0), the force will induce a change in angular velocity as well as linear. | RigidBody | ||
![]() |
addForceGenerator(generator:IForceGenerator):void
Adds a force generator to influence this particle
| SimpleParticle | |
|
addTorque(torque:Number):void
Adds torque to the body
This is the rotational equivalent to adding a force | RigidBody | ||
![]() |
clearForces():void
Clears all forces
| SimpleParticle | |
|
clearTorque():void
Clears any accumulated torque
| RigidBody | ||
|
getDerivative(state:Array, derivative:Array):void
Gets the derivative of the body
Note that both the state and derivative are longer than in SimpleParticle. | RigidBody | ||
|
Gets the velocity of the body at a specified point
Note that this point is given in world-coordinates. | RigidBody | ||
![]() |
removeForceGenerator(generator:IForceGenerator):void
Removes a force generator
| SimpleParticle | |
| Method | Defined by | ||
|---|---|---|---|
|
calculateInertiaTensor():void
Calculates the body's inertia tensor
The inertia tensor is the rotational equivalent to mass- it is also linked to mass. | RigidBody | ||
| av | property |
av:Number [read-write]Implementation
public function get av():Number
public function set av(value:Number):void
| collisionTypeID | property |
collisionTypeID:String [read-only]Implementation
public function get collisionTypeID():String
| _edges | property |
protected var _edges:Arraybody edges
| edges | property |
edges:Array [read-only]Implementation
public function get edges():Array
| _I | property |
protected var _I:Numberinertia tensor
| I | property |
I:Number [read-only]Implementation
public function get I():Number
| _inverseI | property |
protected var _inverseI:Numberinverse inertia tensor
| inverseI | property |
inverseI:Number [read-only]Implementation
public function get inverseI():Number
| q | property |
q:Number [read-write]Implementation
public function get q():Number
public function set q(value:Number):void
| _rotation | property |
protected var _rotation:RotationMatrixrotation matrix of body
| rotation | property |
rotation:RotationMatrix [read-only]Gets the rotation matrix of the body
Because the creation of a rotation matrix involves 2 trigonometric function calls, it's worthwhile to do a check to see if we need to create a new rotation matrix.
Implementation public function get rotation():RotationMatrix
| _torque | property |
protected var _torque:Numbertorque accumulator
| torque | property |
torque:Number [read-only]Implementation
public function get torque():Number
| _vertices | property |
protected var _vertices:Arraybody vertices
| vertices | property |
vertices:Array [read-only]Implementation
public function get vertices():Array
| RigidBody | () | constructor |
public function RigidBody(x:Number, y:Number, mass:Number = 100, vertices:Array = null, vx:Number = 0, vy:Number = 0, friction:Number = 0.2, elasticity:Number = 0.25, q:Number = 0, av:Number = 0)Creates a new RigidBody
This will most likely be the most used element in FOAM. It's important to note that most aspects of simulation assume convexity in bodies.
Parametersx:Number — body's x position
|
|
y:Number — body's y postiion
|
|
mass:Number (default = 100) — body's mass
|
|
vertices:Array (default = null) — body vertices
|
|
vx:Number (default = 0) — horizontal velocity,
|
|
vy:Number (default = 0) — vertical velocity,
|
|
friction:Number (default = 0.2) — body's surface frictional coefficient
|
|
elasticity:Number (default = 0.25) — body's elasticity
|
|
q:Number (default = 0) — body's orientation (in radians)
|
|
av:Number (default = 0) — body's angular velocity
|
See also
| addForceAtPoint | () | method |
public function addForceAtPoint(point:Vector, force:Vector):voidAdds a force at a specific point on the body
IF the point specified is not the center of mass (0,0), the force will induce a change in angular velocity as well as linear. Note that this point is given in relative coordinates to the body- that is NOT in world-coordinates.
Parameterspoint:Vector — point on body relative to its center of mass on which to apply force
|
|
force:Vector — force to apply at point
|
| addTorque | () | method |
public function addTorque(torque:Number):voidAdds torque to the body
This is the rotational equivalent to adding a force
Parameterstorque:Number — amount of torque to add
|
| calculateInertiaTensor | () | method |
protected function calculateInertiaTensor():voidCalculates the body's inertia tensor
The inertia tensor is the rotational equivalent to mass- it is also linked to mass. In 3 dimensions, the inertia tensor is a 3x3 matrix- in 2 dimensions it is a rank 0 tensor, or simply, a scalar.
TODO: This is not very physically accurate, but provides decent resulsts for convex shapes. Improve.| clearTorque | () | method |
public function clearTorque():voidClears any accumulated torque
| getDerivative | () | method |
public override function getDerivative(state:Array, derivative:Array):voidGets the derivative of the body
Note that both the state and derivative are longer than in SimpleParticle. This is because a rigid body has 2 more properties to integrate with respect to time (orientation and angular velocity).
Parametersstate:Array — body's state
|
|
derivative:Array — Array to populate with body's derivative
|
See also
| getVelocityAtPoint | () | method |
public function getVelocityAtPoint(point:Vector):VectorGets the velocity of the body at a specified point
Note that this point is given in world-coordinates.
TODO: why is this given in world coordinates and addForceAtPoint relative? Probably confusing... Parameterspoint:Vector — point to determine velocity from
|
Vector —
componentized velocity
|