fisica
Class FRevoluteJoint

java.lang.Object
  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, float x, float y)
          Construct a revolute joint between two bodies given an anchor position.
 
Method Summary
 void attachImage(processing.core.PImage img)
          Attach an image to the object.
 void dettachImage()
          Dettach any image that has been attached to the object.
 void draw(processing.core.PApplet applet)
           
 void draw(processing.core.PGraphics applet)
          This method is called when calling world.draw().
 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.
 float getImageAlpha()
          Get the opacity with which to draw the attached image.
 boolean isDrawable()
          Get whether the object must be drawn or not.
 void setAnchor(float x, float y)
          Sets the position of the anchor of the joint around which the bodies rotate.
 void setDrawable(boolean drawable)
          Set whether the object must be drawn or not.
 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 setFill(float g)
          Set the fill color of the object.
 void setFill(float g, float a)
          Set the fill color of the object.
 void setFill(float r, float g, float b)
          Set the fill color of the object.
 void setFill(float r, float g, float b, float a)
          Set the fill color of the object.
 void setFillColor(int col)
          Set the fill color of the object.
 void setImageAlpha(float alpha)
          Set the opacity with which to draw the attached image.
 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 setNoFill()
          Set that the object must be drawn without fill.
 void setNoStroke()
          Set that the object must be drawn without stroke.
 void setReferenceAngle(float ang)
           
 void setStroke(float g)
          Set the stroke color of the object.
 void setStroke(float g, float a)
          Set the stroke color of the object.
 void setStroke(float r, float g, float b)
          Set the stroke color of the object.
 void setStroke(float r, float g, float b, float a)
          Set the stroke color of the object.
 void setStrokeColor(int col)
          Set the stroke color of the object.
 void setStrokeWeight(float weight)
          Set the stroke weight of the object.
 void setUpperAngle(float a)
          Set the highest angle allowed.
 
Methods inherited from class fisica.FJoint
getBody1, getBody2, getReactionForceX, getReactionForceY, getReactionTorque, setCollideConnected
 
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
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)
This method is called when calling world.draw(). This method may be overriden to allow custom drawing of the object.

Parameters:
applet - the applet onto which the object must be drawn.

draw

public void draw(processing.core.PApplet applet)

attachImage

public void attachImage(processing.core.PImage img)
Attach an image to the object. This method allows to draw an image onto the screen instead of calling the draw(PApplet) method.

Parameters:
img - the PImage to attach to the object.

dettachImage

public void dettachImage()
Dettach any image that has been attached to the object.

See Also:
attachImage(PImage)

getImageAlpha

public float getImageAlpha()
Get the opacity with which to draw the attached image.

Returns:
the opacity, a value from 0.0 to 1.0 with which to draw the attached image
See Also:
attachImage(PImage), setImageAlpha(float)

setImageAlpha

public void setImageAlpha(float alpha)
Set the opacity with which to draw the attached image.

Parameters:
alpha - the opacity, a value from 0.0 to 1.0 with which to draw the attached image
See Also:
attachImage(PImage), getImageAlpha()

setDrawable

public void setDrawable(boolean drawable)
Set whether the object must be drawn or not.

Parameters:
drawable - if true the object will be drawn, else it will not
See Also:
isDrawable()

isDrawable

public boolean isDrawable()
Get whether the object must be drawn or not.

Returns:
drawable if true the object will be drawn, else it will not
See Also:
setDrawable(boolean)

setFillColor

public void setFillColor(int col)
Set the fill color of the object. This method must be used in conjunction with Processing's color(). In most cases users will find it more convenient to use the versions of setFill(float), setFill(float,float), setFill(float,float,float) or setFill(float,float,float,float)

Parameters:
col - a Processing color type. e.g. myBody.setFillColor(color(20,100,30,90));
See Also:
setNoFill(), setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setNoFill

public void setNoFill()
Set that the object must be drawn without fill.

See Also:
setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setFill

public void setFill(float g)
Set the fill color of the object.

Parameters:
g - gray value
See Also:
setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setFill

public void setFill(float g,
                    float a)
Set the fill color of the object.

Parameters:
g - gray value
a - alpha (opacity) value
See Also:
setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setFill

public void setFill(float r,
                    float g,
                    float b)
Set the fill color of the object.

Parameters:
r - red value
g - green value
b - blue value
See Also:
setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setFill

public void setFill(float r,
                    float g,
                    float b,
                    float a)
Set the fill color of the object.

Parameters:
r - red value
g - green value
b - blue value
a - alpha (opacity) value
See Also:
setFill(float), setFill(float,float), setFill(float,float,float), setFill(float,float,float,float)

setStrokeColor

public void setStrokeColor(int col)
Set the stroke color of the object. This method must be used in conjunction with Processing's color(). In most cases users will find it more convenient to use the versions of setStroke(float), setStroke(float,float), setStroke(float,float,float) or setStroke(float,float,float,float)

Parameters:
col - a Processing color type. e.g. myBody.setStrokeColor(color(20,100,30,90));
See Also:
setNoStroke(), setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setNoStroke

public void setNoStroke()
Set that the object must be drawn without stroke.

See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setStroke

public void setStroke(float g)
Set the stroke color of the object.

Parameters:
g - gray value
See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setStroke

public void setStroke(float g,
                      float a)
Set the stroke color of the object.

Parameters:
g - gray value
a - alpha (opacity) value
See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setStroke

public void setStroke(float r,
                      float g,
                      float b)
Set the stroke color of the object.

Parameters:
r - red value
g - green value
b - blue value
See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setStroke

public void setStroke(float r,
                      float g,
                      float b,
                      float a)
Set the stroke color of the object.

Parameters:
r - red value
g - green value
b - blue value
a - alpha (opacity) value
See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)

setStrokeWeight

public void setStrokeWeight(float weight)
Set the stroke weight of the object.

Parameters:
weight - weight value in pixels
See Also:
setStroke(float), setStroke(float,float), setStroke(float,float,float), setStroke(float,float,float,float)


processing library fisica by Ricard Marxer. (c) 2009