fisica
Class FRevoluteJoint

java.lang.Object
  extended by fisica.FDrawable
      extended by fisica.FJoint
          extended by fisica.FRevoluteJoint

public class FRevoluteJoint
extends FJoint

Represents a revolute joint that restricts the movement of one body with respect to another to rotation around a given anchor. The rotation can be further limited given a lower and un upper angles. Additionally the user can enable a motor in order to apply a constant rotation force (torque) to the joint in order to reach the desired rotation speed.


Constructor Summary
FRevoluteJoint(FBody body1, FBody body2)
          Construct a revolute joint between two bodies.
FRevoluteJoint(FBody body1, FBody body2, float x, float y)
          Construct a revolute joint between two bodies given an anchor position.
 
Method Summary
 void draw(processing.core.PGraphics applet)
          This method is called when calling world.draw().
 void drawDebug(processing.core.PGraphics applet)
          This method is called when calling world.drawDebug().
 float getAnchorX()
          Get the horizontal coordinate of the anchor of the joint around which the bodies can rotate.
 float getAnchorY()
          Get the vertical coordinate of the anchor of the joint around which the bodies can rotate.
 void setAnchor(float x, float y)
          Sets the position of the anchor of the joint around which the bodies rotate.
 void setEnableLimit(boolean value)
          Set limits to the allowed rotation of one body respect to the other.
 void setEnableMotor(boolean value)
          Set the state of the motor in order to generate a rotation force (torque) on the joint.
 void setLowerAngle(float a)
          Set the lowest angle allowed.
 void setMaxMotorTorque(float a)
          Set the maximum torque that the joint's motor can apply in order to acheive the desired speed.
 void setMotorSpeed(float a)
          Set the desired rotation speed of the joint.
 void setReferenceAngle(float ang)
           
 void setUpperAngle(float a)
          Set the highest angle allowed.
 
Methods inherited from class fisica.FJoint
addToWorld, getBody1, getBody2, getBox2dJoint, getReactionForceX, getReactionForceY, getReactionTorque, removeFromWorld, setCollideConnected
 
Methods inherited from class fisica.FDrawable
attachImage, dettachImage, draw, drawDebug, getFillColor, getImageAlpha, isDrawable, setDrawable, setFill, setFill, setFill, setFill, setFillColor, setImageAlpha, setNoFill, setNoStroke, setStroke, setStroke, setStroke, setStroke, setStrokeColor, setStrokeWeight
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FRevoluteJoint

public FRevoluteJoint(FBody body1,
                      FBody body2,
                      float x,
                      float y)
Construct a revolute joint between two bodies given an anchor position.

Parameters:
body1 - first body of the joint
body2 - second body of the joint
x - horizontal coordinate of the anchor given in global coordinates, relative to the canvas' center
y - vertical coordinate of the anchor given in global coordinates, relative to the canvas' center

FRevoluteJoint

public FRevoluteJoint(FBody body1,
                      FBody body2)
Construct a revolute joint between two bodies.

Parameters:
body1 - first body of the joint
body2 - second body of the joint
Method Detail

setLowerAngle

public void setLowerAngle(float a)
Set the lowest angle allowed. This property only has effect if the enableLimit has been set to true using setEnableLimit(boolean).

Parameters:
a - lowest angle allowed in radians

setUpperAngle

public void setUpperAngle(float a)
Set the highest angle allowed. This property only has effect if the enableLimit has been set to true using setEnableLimit(boolean).

Parameters:
a - highest angle allowed in radians

setEnableLimit

public void setEnableLimit(boolean value)
Set limits to the allowed rotation of one body respect to the other. If set to true the limits imposed using setLowerAngle and setLowerAngle are enforced.

Parameters:
value - if true the bodies will be able to rotate around the anchor only between certain limits

setMotorSpeed

public void setMotorSpeed(float a)
Set the desired rotation speed of the joint. This property only has effect if the enableMotor has been set to true using setEnableMotor(boolean). The speed is given in radians per second.

Parameters:
a - the desired speed in radians per second

setMaxMotorTorque

public void setMaxMotorTorque(float a)
Set the maximum torque that the joint's motor can apply in order to acheive the desired speed. This property only has effect if the enableMotor has been set to true using setEnableMotor(boolean).

Parameters:
a - the maximum torque of the joint's motor

setEnableMotor

public void setEnableMotor(boolean value)
Set the state of the motor in order to generate a rotation force (torque) on the joint. If set to true the desired motor speed, set using setMotorSpeed, will try to be matched using a motor with a maximum rotation force (torque) set using setMaxMotorTorque.

Parameters:
value - if true the joint will receive the rotation force (torque) of a motor

setAnchor

public void setAnchor(float x,
                      float y)
Sets the position of the anchor of the joint around which the bodies rotate. This position is given global coordinates, relative to the center of the canvas.

Parameters:
x - the horizontal coordinate of the anchor in global coordinates, relative to the center of the canvas
y - the vertical coordinate of the anchor in global coordinates, relative to the center of the canvas

getAnchorX

public float getAnchorX()
Get the horizontal coordinate of the anchor of the joint around which the bodies can rotate. This position is given global coordinates, relative to the center of the canvas.

Returns:
the horizontal coordinate of the anchor in global coordinates, relative to the center of the canvas

getAnchorY

public float getAnchorY()
Get the vertical coordinate of the anchor of the joint around which the bodies can rotate. This position is given global coordinates, relative to the center of the canvas.

Returns:
the vertical coordinate of the anchor in global coordinates, relative to the center of the canvas

setReferenceAngle

public void setReferenceAngle(float ang)

draw

public void draw(processing.core.PGraphics applet)
Description copied from class: FDrawable
This method is called when calling world.draw(). This method may be overriden to allow custom drawing of the object.

Overrides:
draw in class FDrawable
Parameters:
applet - the graphics onto which the object must be drawn.

drawDebug

public void drawDebug(processing.core.PGraphics applet)
Description copied from class: FDrawable
This method is called when calling world.drawDebug(). This method may be overriden to allow custom debug drawing of the object.

Overrides:
drawDebug in class FDrawable
Parameters:
applet - the graphics onto which the object must be drawn.


processing library fisica by Ricard Marxer. (c) 2009-2013