Changes

Jump to navigation Jump to search

Category:Physics Engine/Bodies

33,691 bytes added, 10:42, 18 July 2012
no edit summary
Line 1: Line 1: −
A body holds the physical properties (mass, position, rotation, velocity, etc.) of an object.<br>It does not have a shape until you attach one (or more) to it. Its type is TI.cpBody.  
+
A body holds the physical properties (mass, position, rotation, velocity, etc.) of an object. It does not have a [[#Shape|shape]] until you attach one (or more) to it.  
 +
Its type is TI.cpBody.
 +
 
 +
 
 +
===== Body =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
body = physics.Body(mass, inertia)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  mass
 +
|  '''in''' number
 +
|  Mass of the body
 +
|-
 +
|  inertia
 +
|  '''in''' number
 +
|  The inertia of the body
 +
|-
 +
|  body
 +
|  '''out''' physics.Body
 +
|  A new Body with the supplied mass and inertia
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns a new Body with the given mass and moment of inertia.
 +
 
 +
Use the [[#inertia|provided helper functions]] to compute the moment of inertia.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== activate =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:activate()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Activates a sleeping body.
 +
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#D8E4F1;"
 +
|-
 +
|  <span style="color:#0000AA">'''INFO'''</span><hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
See [[http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/ http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/]] for an explanation of this routine.
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== angle =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
angle = physics.Body:angle()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  angle
 +
|  '''out''' number
 +
|  The angle of the Body in radians
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the angle in radians of the orientation of the body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== angVel =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
avel = physics.Body:angVel()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  avel
 +
|  '''out''' number
 +
|  The angular velocity of the Body in radians per unit time
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the angular velocity of the body in radians per unit time.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== applyForce =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:applyForce(forceVect, rOffset)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  forceVect
 +
|  '''in''' physics.Vect
 +
|  A force vector
 +
|-
 +
|  rOffset
 +
|  '''in''' physics.Vect
 +
|  Vector offset of the force relative to the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Apply force [[#vector|vector]] on ''self'' at a relative offset from the center of gravity.
 +
 
 +
Introducted in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== applyImpulse =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:applyImpulse(impulseVect, rOffset)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  impulseVect
 +
|  '''in''' physics.Vect
 +
|  Impulse force on the Body
 +
|-
 +
|  rOffset
 +
|  '''in''' physics.Vect
 +
|  Vector offset of the force relative to the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Apply the impulse [[#vector|vector]] to ''self'' at a relative offset from the center of gravity.
 +
 
 +
Introducted in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== data =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
obj = physics.Body:data()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  obj
 +
|  '''out''' Lua object
 +
|  An object previously set on the Body by the programmer
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the contents of the programmer data field of the Body.
 +
 
 +
Introducted in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== force =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
fvec = physics.Body:force()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  fvec
 +
|  '''out''' physics.Vect
 +
|  The force vector on the Body
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the force [[#vector|vector]] on the body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== isRogue =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
bool = physics.Body:isRogue()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  bool
 +
|  '''out''' boolean
 +
|  True if the Body is a rogue Body
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns true if the Body is a rogue Body, never having been added to the simulation [[#Space|Space]].
 +
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#D8E4F1;"
 +
|-
 +
|  <span style="color:#0000AA">'''INFO'''</span><hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
See [[http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/ http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/]] for an explanation of rogue bodies.
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== isSleeping =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
bool = physics.Body:isSleeping()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  bool
 +
|  '''out''' boolean
 +
|  True if the Body is sleeping
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns true if the body is sleeping.
 +
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#D8E4F1;"
 +
|-
 +
|  <span style="color:#0000AA">'''INFO'''</span><hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
See [[http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/ http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/]] for an explanation of sleeping bodies.
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== local2World =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
wvec = physics.Body:local2World(lvec)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  lvec
 +
|  '''in''' physics.Vect
 +
|  A vector relative to the position of the Body
 +
|-
 +
|  wvec
 +
|  '''out''' physics.Vect
 +
|  A vector in world coordinates
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Converts ''lvec'' from body-relative coordinates to world coordinates. Returns the converted [[#vector|vector]].
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== kineticEnergy =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
ke = physics.Body:kineticEnergy()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  ke
 +
|  '''out''' number
 +
|  The total kinetic energy of the Body
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the kinetic energy of the body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== mass =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
m = physics.Body:mass()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  m
 +
|  '''out''' number
 +
|  The mass of the Body
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the mass of the body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== moment =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
m = physics.Body:moment()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  m
 +
|  '''out''' number
 +
|  The moment of inertia of the Body
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the moment of inertia of the body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== pos =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
p = physics.Body:pos()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  p
 +
|  '''out''' physics.Vect
 +
|  The position of the Body
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the [[#vector|vector]] position of the body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== resetForces =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:resetForces()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Zero both the force and torque accumulated on ''self''.
 +
 
 +
Introducted in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== rot =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
rvec = physics.Body:rot()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  rvec
 +
|  '''out''' physics.Vect
 +
|  The unit vector orientation of the Body
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the [[#vector|vector]] orientation of the body. This is a unit vector cached from the last calculated angle of the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setAngle =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setAngle(angle)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  angle
 +
|  '''in''' number
 +
|  The angle of rotation in radians of the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Updates the angle of rotation in radians of the body.
 +
 
 +
Returns the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setAngVel =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setAngVel(vel)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  vel
 +
|  '''in''' number
 +
|  The angular velocity in radians per unit time of the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Updates the angular velocity of the body. The angular velocity is in radians per unit time.
 +
 
 +
Returns the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setData =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setData(value)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  value
 +
|  '''in''' object
 +
|  A programmer-supplied Lua object
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Sets the programmer data field of the Body. The programmer can store any Lua object in this field. This is a handy place to store a reference to a simulation object.
 +
 
 +
Returns the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setForce =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setForce(vector)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  vector
 +
|  '''in''' physics.Vect
 +
|  The vector of force on the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Updates the force [[#vector|vector]] on the body.
 +
 
 +
Returns the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setMass =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setMass(mass)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  mass
 +
|  '''in''' number
 +
|  The mass of the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Updates the mass of the body.
 +
 
 +
Returns the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setMoment =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setMoment(moment)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  moment
 +
|  '''in''' number
 +
|  The moment of inertia of the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Updates the moment of inertia of the body.
 +
 
 +
Use the [[#inertia|provided helper functions]] to compute the moment of inertia.
 +
 
 +
Returns the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setPos =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setPos(vector)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  vector
 +
|  '''in''' physics.Vect
 +
|  The position of the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Updates the position of the body.
 +
 
 +
Returns the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setPositionFunc =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setPositionFunc(func)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  func
 +
|  '''in''' function(body, dt)
 +
|  A callback function that updates the position of the Body on each time step
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Sets the position function of the body. The position function must be a function that accepts a Body and a time step value and at some point calls body:updatePosition to update the position of the body.
 +
 
 +
Returns the Body.
 +
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#ddffdd;"
 +
|-
 +
|  <span style="color:#00AA00">'''TIP''':</span> '''Example'''<hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
-- TODO This is a lame example
 +
 
 +
function samplePositionFunc(body, dt)
 +
-- What goes here?
 +
body:updatePosition(dt)
 +
end
 +
 
 +
body:setPositionFunc(samplePositionFunc)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setTorque =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setTorque(torque)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  torque
 +
|  '''in''' number
 +
|  The torque of the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Updates the torque on the body. Torque is a numeric magnitude.
 +
 
 +
Returns the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setVel =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setVel(vector)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  vector
 +
|  '''in''' physics.Vect
 +
|  The velocity vector of the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Updates the velocity of the body.
 +
 
 +
Returns the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setVelocityFunc =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setVelocityFunc(func)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  func
 +
|  '''in''' function(body, grav, damping, dt)
 +
|  A callback function that updates the velocity of the Body on each time step
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Sets the velocity function of the body. The velocity function must be a function that accepts a Body, a gravity [[#vector|vector]], a numeric damping factor, and a time step value. The function should call body:updateVelocity to adjust the velocity of the body.
 +
 
 +
Returns the Body.
 +
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#ddffdd;"
 +
|-
 +
|  <span style="color:#00AA00">'''TIP''':</span> '''Example'''<hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
function sampleVelocityFunc(body, gravity, damping, dt)
 +
local pos = body:pos()
 +
local sqdist = pos:lengthsq()
 +
local g = pos:mult(-GravityStrength / (sqdist * math.sqrt(sqdist)))
 +
body:updateVelocity(g, damping, dt)
 +
end
 +
 
 +
body:setVelocityFunc(sampleVelocityFunc)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setVLimit =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setVLimit(limit)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  limit
 +
|  '''in''' number
 +
|  The maximum speed of the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Sets the limit for the maximum speed of the body.
 +
 
 +
Returns the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setWLimit =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:setWLimit(limit)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  limit
 +
|  '''in''' number
 +
|  The maximum angular velocity of the Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Updates the limit of the angular velocity of the body. Angular velocity is in radians per unit time.
 +
 
 +
Returns the Body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== sleep =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:sleep()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Puts the body to sleep.
 +
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#D8E4F1;"
 +
|-
 +
|  <span style="color:#0000AA">'''INFO'''</span><hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
See [[http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/ http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/]] for an explanation of sleeping bodies.
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
 +
|-
 +
|  <span style="color:#AAAA00">'''NOTE''':</span> '''NOTES'''<hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
The body must be added to a [[#Space|Space]] before it can be put to sleep.
 +
 
 +
Calling this function within a query or callback is not allowed.
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== sleepWithGroup =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Body:sleepWithGroup( [group] )
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  group
 +
|  '''in''' physics.Body
 +
|  A sleeping body. If this parameter is not supplied, a new group is created
 +
|-
 +
|  self
 +
|  '''out''' physics.Body
 +
|  The input Body is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Puts the Body to sleep and adds it to a group of other sleeping bodies.
 +
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#D8E4F1;"
 +
|-
 +
|  <span style="color:#0000AA">'''INFO'''</span><hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
See [[http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/ http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/]] for an explanation of this routine.
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
 +
|-
 +
|  <span style="color:#AAAA00">'''NOTE''':</span> '''NOTE'''<hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
The body must be added to a [[#Space|Space]] before it can be put to sleep.
 +
 
 +
Calling this function within a query or callback is not allowed.
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
This routine will raise an exception if ''group'' is not sleeping.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== torque =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
t = physics.Body:torque()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  torque
 +
|  '''out''' number
 +
|  The torque on the Body
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the torque on the body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== updatePosition =====
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
physics.Body:updatePosition(dt)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  dt
 +
|  '''in''' number
 +
|  The time interval in seconds
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Updates the position of the body using Euler integration.
 +
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#D8E4F1;"
 +
|-
 +
|  <span style="color:#0000AA">'''INFO'''</span><hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
See [[http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/ http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/]] for an explanation of this routine.
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== updateVelocity =====
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
physics.Body:updateVelocity(grav, damp, dt)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  grav
 +
|  '''in''' physics.Vect
 +
|  The force of gravity
 +
|-
 +
|  damp
 +
|  '''in''' physics.Vect
 +
|  The damping factor
 +
|-
 +
|  dt
 +
|  '''in''' physics.Vect
 +
|  The time interval in seconds
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Updates the velocity of the body using Euler integration.
 +
{| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#D8E4F1;"
 +
|-
 +
|  <span style="color:#0000AA">'''INFO'''</span><hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
See [[http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/ http://files.slembcke.net/chipmunk/release/Chipmunk-5.x/Chipmunk-5.3.4-Docs/]] for an explanation of this routine.
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== vel =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
vvel = physics.Body:vel()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  vvel
 +
|  '''out''' physics.Vect
 +
|  The velocity of the Body
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the [[#vector|vector]] velocity of the body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== vLimit =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
vmax = physics.Body:vLimit()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  vmax
 +
|  '''out''' number
 +
|  The maximum speed of the Body
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the speed limit of the body.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== wLimit =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
wmax = physics.Body:wLimit()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  wmax
 +
|  '''out''' number
 +
|  The maximum angular velocity of the Body in radians per unit time
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the angular velocity limit of the body. The angular velocity is in radians per unit time.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== world2Local =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
lvec = physics.Body:world2Local(wvec)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Body
 +
|  The input Body
 +
|-
 +
|  wvec
 +
|  '''in''' physics.Vect
 +
|  A vector in world coordinates
 +
|-
 +
|  lvec
 +
|  '''out''' physics.Vect
 +
|  A vector relative to the position of the Body
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Converts ''wvec'' from world coordinates to body-relative coordinates. Returns the converted [[#vector|vector]].
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
    
[[Category:Physics_Engine]]
 
[[Category:Physics_Engine]]

Navigation menu