• core
  • Context
  • ElementAllocator
  • ElementOutput
  • Engine
  • Entity
  • EventEmitter
  • EventHandler
  • Group
  • Modifier
  • OptionsManager
  • RenderNode
  • Scene
  • SpecParser
  • Transform
  • View
  • ViewSequence
  • events
  • EventArbiter
  • EventFilter
  • EventMapper
  • inputs
  • Accumulator
  • GenericSync
  • MouseSync
  • PinchSync
  • RotateSync
  • ScaleSync
  • ScrollSync
  • TouchSync
  • TouchTracker
  • TwoFingerSync
  • math
  • Matrix
  • Quaternion
  • Random
  • Utilities
  • Vector
  • modifiers
  • Draggable
  • Fader
  • ModifierChain
  • StateModifier
  • physics
  • PhysicsEngine
  • physics/bodies
  • Body
  • Circle
  • Particle
  • Rectangle
  • physics/constraints
  • Surface
  • Collision
  • Constraint
  • Curve
  • Distance
  • Snap
  • Wall
  • Walls
  • physics/forces
  • Drag
  • Force
  • Repulsion
  • RotationalDrag
  • RotationalSpring
  • Spring
  • VectorField
  • physics/integrators
  • SymplecticEuler
  • surfaces
  • CanvasSurface
  • ContainerSurface
  • ImageSurface
  • InputSurface
  • TextareaSurface
  • VideoSurface
  • transitions
  • CachedMap
  • Easing
  • MultipleTransition
  • SnapTransition
  • SpringTransition
  • Transitionable
  • TransitionableTransform
  • TweenTransition
  • WallTransition
  • utilities
  • KeyCodes
  • Timer
  • Utility
  • views
  • ContextualView
  • Deck
  • DrawerLayout
  • EdgeSwapper
  • FlexibleLayout
  • Flipper
  • GridLayout
  • HeaderFooterLayout
  • Lightbox
  • RenderController
  • ScrollContainer
  • Scroller
  • Scrollview
  • SequentialLayout
  • widgets
  • NavigationBar
  • TabBar

Body

A unit controlled by the physics engine which extends the zero-dimensional Particle to include geometry. In addition to maintaining the state of a Particle its state includes orientation, angular velocity and angular momentum and responds to torque forces.

Overview

Methods
setMomentsOfInertiaupdateAngularVelocitytoWorldCoordinatesgetEnergyresetsetOrientationsetAngularVelocitysetAngularMomentumapplyForceapplyTorquegetTransformintegrateAngularMomentumintegrateOrientation
Methods

setMomentsOfInertia()

Setter for moment of inertia, which is necessary to give proper angular inertia depending on the geometry of the body.

updateAngularVelocity()

Update the angular velocity from the angular momentum state.

toWorldCoordinates(localPosition)

Determine world coordinates from the local coordinate system. Useful if the Body has rotated in space.

Parameters
localPosition
Vector
local coordinate vector
Returns
Vector
global coordinate vector

getEnergy()

Calculates the kinetic and intertial energy of a body.

Returns
Number
energy

reset(p, v, q, L)

Extends Particle.reset to reset orientation, angular velocity and angular momentum.

Parameters
p
Array|Vector
position
v
Array|Vector
velocity
q
Array|Quaternion
orientation
L
Array|Vector
angular momentum

setOrientation(q)

Setter for orientation

Parameters
q
Array|Quaternion
orientation

setAngularVelocity(w)

Setter for angular velocity

Parameters
w
Array|Vector
angular velocity

setAngularMomentum(L)

Setter for angular momentum

Parameters
L
Array|Vector
angular momentum

applyForce(force, location)

Extends Particle.applyForce with an optional argument to apply the force at an off-centered location, resulting in a torque.

Parameters
force
Vector
force
location
Vector
off-center location on the body

applyTorque(torque)

Applied a torque force to a body, inducing a rotation.

Parameters
torque
Vector
torque

getTransform()

Extends Particle.getTransform to include a rotational component derived from the particle's orientation.

Returns
Transform
transform

getTransform(dt)Protected

Extends Particle._integrate to also update the rotational states of the body.

Parameters
dt
Number
delta time

integrateAngularMomentum(dt)

Updates the angular momentum via the its integrator.

Parameters
dt
Number
delta time

integrateOrientation(dt)

Updates the orientation via the its integrator.

Parameters
dt
Number
delta time