fisica
Class FPrismaticJoint

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

public class FPrismaticJoint
extends FJoint

Represents a prismatic joint that restricts the movement of one body with respect to another to a translation along a given axis. Often this joint is used with one of the bodies being static in order to only allow translation of the other body along a given axis. This translation can also be bounded given lower and upper translation limits.


Constructor Summary
FPrismaticJoint(FBody body1, FBody body2)
          Construct a prismatic joint between two bodies.
 
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.
 float getAnchorY()
          Get the vertical coordinate of the anchor of the joint.
 void setAnchor(float x, float y)
          Sets the position of the anchor of the joint.
 void setAxis(float x, float y)
          Sets the axis of movement of the joint.
 void setEnableLimit(boolean value)
          Set limits to the allowed translation of one body respect to the other.
 void setLowerTranslation(float translation)
          Set the lowest translation allowed.
 void setUpperTranslation(float translation)
          Set the highest translation 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

FPrismaticJoint

public FPrismaticJoint(FBody body1,
                       FBody body2)
Construct a prismatic joint between two bodies. The constructor automatically sets the anchor of the joint to the center of the second body.

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

setAxis

public void setAxis(float x,
                    float y)
Sets the axis of movement of the joint. This is only axis alog which the bodies can translate with relation to each other. The axis is given global coordinates, relative to the center of the canvas. This property must be set before adding the joint to the world.

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

setAnchor

public void setAnchor(float x,
                      float y)
Sets the position of the anchor of the joint. 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. 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. 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

setLowerTranslation

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

Parameters:
translation - lowest translation position in pixels

setUpperTranslation

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

Parameters:
translation - highest translation position in pixels

setEnableLimit

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

Parameters:
value - if true the bodies will be able to translate along the axis only between certain limits

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