Difference between revisions of "B2.RevoluteJoint"

From GiderosMobile
Line 5: Line 5:
 
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
 
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
 
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/b2.Joint|b2.Joint]]<br/>
 
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/b2.Joint|b2.Joint]]<br/>
 +
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
<translate><br />
+
A revolute joint constrains two bodies to share a common point while they are free to rotate about the point. The relative rotation about the shared point is the joint angle. You can limit the relative rotation with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation about the shared point. A maximum motor torque is provided so that infinite forces are not generated.
A revolute joint constrains two bodies to share a common point while they are free to rotate about the point. The relative rotation about the shared point is the joint angle. You can limit the relative rotation with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation about the shared point. A maximum motor torque is provided so that infinite forces are not generated. <br />
+
 
<br /></translate>
 
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
'''Revolute joint'''<br/>
+
'''Revolute joint'''
<source lang="lua">--create empty box2d body for joint
+
<source lang="lua">
 +
--create empty box2d body for joint
 
local ground = world:createBody({})
 
local ground = world:createBody({})
 
ground:setPosition(300, 480)
 
ground:setPosition(300, 480)
Line 19: Line 20:
 
--will not let ball spin for ever
 
--will not let ball spin for ever
 
revoluteJoint:setMaxMotorTorque(1)
 
revoluteJoint:setMaxMotorTorque(1)
revoluteJoint:enableMotor(true)</source>
+
revoluteJoint:enableMotor(true)
 +
</source>
 +
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
Line 35: Line 38:
 
[[Special:MyLanguage/b2.RevoluteJoint:setMaxMotorTorque|b2.RevoluteJoint:setMaxMotorTorque]] ''<translate>sets the maximum motor torque in N*m</translate>''<br/><!-- GIDEROSMTD:b2.RevoluteJoint:setMaxMotorTorque(torque) sets the maximum motor torque in N*m -->
 
[[Special:MyLanguage/b2.RevoluteJoint:setMaxMotorTorque|b2.RevoluteJoint:setMaxMotorTorque]] ''<translate>sets the maximum motor torque in N*m</translate>''<br/><!-- GIDEROSMTD:b2.RevoluteJoint:setMaxMotorTorque(torque) sets the maximum motor torque in N*m -->
 
[[Special:MyLanguage/b2.RevoluteJoint:setMotorSpeed|b2.RevoluteJoint:setMotorSpeed]] ''<translate>sets the motor speed in radians per second</translate>''<br/><!-- GIDEROSMTD:b2.RevoluteJoint:setMotorSpeed(speed) sets the motor speed in radians per second -->
 
[[Special:MyLanguage/b2.RevoluteJoint:setMotorSpeed|b2.RevoluteJoint:setMotorSpeed]] ''<translate>sets the motor speed in radians per second</translate>''<br/><!-- GIDEROSMTD:b2.RevoluteJoint:setMotorSpeed(speed) sets the motor speed in radians per second -->
 +
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Events</translate> ===
 
=== <translate>Events</translate> ===
 
=== <translate>Constants</translate> ===
 
=== <translate>Constants</translate> ===
 
|}
 
|}
 +
 +
----
 +
*'''[[LiquidFun]]'''

Revision as of 02:51, 18 February 2020


Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2011.6
Inherits from: b2.Joint

Description

A revolute joint constrains two bodies to share a common point while they are free to rotate about the point. The relative rotation about the shared point is the joint angle. You can limit the relative rotation with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation about the shared point. A maximum motor torque is provided so that infinite forces are not generated.

Examples

Revolute joint

--create empty box2d body for joint
local ground = world:createBody({})
ground:setPosition(300, 480)

local jointDef = b2.createRevoluteJointDef(body, ground, 300, 300)
local revoluteJoint = world:createJoint(jointDef)
--will not let ball spin for ever
revoluteJoint:setMaxMotorTorque(1)
revoluteJoint:enableMotor(true)

Methods

b2.RevoluteJoint:enableLimit enables or disables the joint limit
b2.RevoluteJoint:enableMotor enables or disables the joint motor
b2.RevoluteJoint:getJointAngle returns the current joint angle in radians
b2.RevoluteJoint:getJointSpeed returns the current joint angle speed in radians per second
b2.RevoluteJoint:getLimits returns the lower and upper joint limit in radians
b2.RevoluteJoint:getMotorSpeed returns the motor speed in radians per second
b2.RevoluteJoint:getMotorTorque returns the current motor torque given the inverse time step
b2.RevoluteJoint:isLimitEnabled is the joint limit enabled?
b2.RevoluteJoint:isMotorEnabled is the joint motor enabled?
b2.RevoluteJoint:setLimits sets the joint limits in radians
b2.RevoluteJoint:setMaxMotorTorque sets the maximum motor torque in N*m
b2.RevoluteJoint:setMotorSpeed sets the motor speed in radians per second

Events

Constants