org.jbox2d.p5
Class Physics

java.lang.Object
  extended by org.jbox2d.p5.Physics

public class Physics
extends java.lang.Object

A wrapper class to make using JBox2d with Processing dead simple.

The basics...

Required import:

 import org.jbox2d.p5.*;
Optional imports (if you're doing anything substantial with the physical objects, you'll want some or all of these), ordered by the likelihood of your needing them:
 import org.jbox2d.common.*;
 import org.jbox2d.dynamics.*;
 import org.jbox2d.dynamics.joints.*;
 import org.jbox2d.collision.*;
 import org.jbox2d.dynamics.contacts.*;
The above files make up the full JBox2d library. If you're worried about importing too much stuff, you're welcome to figure out exactly what you do and don't need, but there are way too many class files to go through individually here.

It is recommended that you run your sketch at 60 fps, as that is the speed that physics is simulated at. The physics simulation is not connected to the sketch frame rate, so even if your sketch runs at 30 fps, the physics will still advance by 1/60 of a second every frame. You can change the time step by doing physics.getSettings().hz = newFrequency; but bear in mind that this engine is only properly tuned for 60 hz, so you might get instability or poor quality if you do so.

To create a world fitted to your sketch size, assuming that sketchWidth and sketchHeight are both set to the proper values AND the sketch has completely initialized (threading bugs in some recent Processing versions have caused proper size initialization to be delayed until a couple of runs into the draw loop - if the JBox2d drawer seems to be initialized to the wrong size, you probably need to delay this call until a few frames in to the sketch run), do the following:
 Physics physics = new Physics(this, sketchWidth, sketchHeight);
You do not need to add anything special to your draw loop to cause the physics to be simulated and/or rendered. This is done automatically.

The default setup (as above) sets up a scaling factor so that 10 pixels = 1 meter. Most functions in this wrapper use pixel units, so you may position things naturally in screen space. However, Processing transformations (scale, translate, rotate) are not taken into account.

If you need to do something in world coordinates (for instance, the gravity vector in the alternate constructor is specified in meters, not pixels), you can use the worldToScreen and screenToWorld functions to convert back and forth.

To destroy a world:
 physics.destroy();
To create a static (immobile) body:
 physics.setDensity(0.0f);
 physics.createRect(x0, y0, x1, y1);
To create a normal moving body:
 physics.setDensity(someNonZeroDensity);
 physics.createRect(x0, y0, x1, y1);
You can also setFriction(float) and setRestitution(float) to change the way your objects collide. This wrapper retains the last set values, much like Processing does with stroke and fill.

Of course there are more features (joints, sensors, continuous collision detection, custom rendering routines, and more to come!), but for that, please see the rest of the documentation. Enjoy!

Author:
ewjordan

Constructor Summary
Physics(processing.core.PApplet parent, float screenW, float screenH)
          Set up a default physics world.
Physics(processing.core.PApplet parent, float screenW, float screenH, float gravX, float gravY, float screenAABBWidth, float screenAABBHeight, float borderBoxWidth, float borderBoxHeight, float pixelsPerMeter)
          Set up a physics world.
 
Method Summary
 void applyForce(org.jbox2d.dynamics.Body b, float fx, float fy)
          Apply a force to the body at the center of mass.
 void applyForce(org.jbox2d.dynamics.Body b, float fx, float fy, float pointX, float pointY)
          Apply a force to a body at a point.
 void applyForce(org.jbox2d.dynamics.Body b, org.jbox2d.common.Vec2 f)
          Apply a force to the body at the center of mass.
 void applyForce(org.jbox2d.dynamics.Body b, org.jbox2d.common.Vec2 f, org.jbox2d.common.Vec2 point)
          Apply a force to a body at a point
 org.jbox2d.dynamics.Body createCircle(float x, float y, float r)
          Create a circle in screen coordinates
 org.jbox2d.dynamics.joints.DistanceJoint createDistanceJoint(org.jbox2d.dynamics.Body a, org.jbox2d.dynamics.Body b, float xa, float ya, float xb, float yb)
          Create a distance (stick) joint between two bodies that holds the specified points at a constant distance.
 org.jbox2d.dynamics.joints.GearJoint createGearJoint(org.jbox2d.dynamics.joints.Joint pj1, org.jbox2d.dynamics.joints.Joint pj2, float ratio)
          Create a gear joint, which binds together two existing revolute or prismatic joints (any combination will work).
 org.jbox2d.dynamics.Body[] createHollowBox(float centerX, float centerY, float width, float height, float thickness)
          Create a hollow box of the given screen dimensions.
 org.jbox2d.dynamics.Body createPolygon(float... vertices)
          Create a polygon based on vertices.
 org.jbox2d.dynamics.joints.PrismaticJoint createPrismaticJoint(org.jbox2d.dynamics.Body a, org.jbox2d.dynamics.Body b, float dirX, float dirY)
          Create a prismatic (piston) joint between two bodies that allows movement in the given direction.
 org.jbox2d.dynamics.joints.PulleyJoint createPulleyJoint(org.jbox2d.dynamics.Body a, org.jbox2d.dynamics.Body b, float groundAnchorAx, float groundAnchorAy, float groundAnchorBx, float groundAnchorBy, float anchorAx, float anchorAy, float anchorBx, float anchorBy, float ratio)
          Create a pulley joint between the The pulley joint is connected to two bodies and two fixed ground points.
 org.jbox2d.dynamics.Body createRect(float x0, float y0, float x1, float y1)
          Create a rectangle given by screen coordinates of corners.
 org.jbox2d.dynamics.joints.RevoluteJoint createRevoluteJoint(org.jbox2d.dynamics.Body a, org.jbox2d.dynamics.Body b, float x, float y)
          Create a revolute (pin) joint between the two bodies at the given position.
 void defaultDraw(org.jbox2d.dynamics.World world)
          Draws the scene using the default render options.
 void destroy()
          Destroy this world, unregistering it from the PApplet.
 void draw()
          Called automatically by Processing.
 float getAngle(org.jbox2d.dynamics.Body b)
          Get the angle (in radians)
 org.jbox2d.dynamics.Body[] getBorder()
          Get the border Body[] array, or null if the border has been removed.
 boolean getBullet()
          Are newly created bodies being created as bullets?
 org.jbox2d.common.Vec2 getCMPosition(org.jbox2d.dynamics.Body b)
          Get the center of mass position (screen coordinates)
 float getDensity()
          Get the density being used for newly created shapes.
 float getFriction()
          Get the friction being used for newly created shapes.
 org.jbox2d.common.Vec2 getPosition(org.jbox2d.dynamics.Body b)
          Get the location of the body's origin (screen coordinates) - note that this does not usually correspond to the center of mass position, which may be obtained by calling getCMPosition(Body).
 float getRestitution()
          Get the restitution being used for newly created shapes.
 boolean getSensor()
          Are newly created shapes being created as sensors?
 org.jbox2d.testbed.TestSettings getSettings()
          Get an editable copy of the current TestSettings so that you may change certain aspects of the simulation and display.
 org.jbox2d.dynamics.World getWorld()
          Get the current physics world.
 void removeBody(org.jbox2d.dynamics.Body b)
          Remove a body from the world.
 void removeBorder()
          Remove the solid border if it exists.
 void removeJoint(org.jbox2d.dynamics.joints.Joint j)
          Remove a joint from the world.
 float screenToWorld(float length)
          Screen space to world space conversion for length.
 org.jbox2d.common.Vec2 screenToWorld(float x, float y)
          Screen space to world space conversion for position.
 org.jbox2d.common.Vec2 screenToWorld(org.jbox2d.common.Vec2 v)
          Screen space to world space conversion for position.
 org.jbox2d.common.Vec2 screenToWorldVector(float sx, float sy)
           
 org.jbox2d.common.Vec2 screenToWorldVector(org.jbox2d.common.Vec2 screenV)
           
 float screenToWorldX(float x, float y)
          Screen space to world space conversion for position.
 float screenToWorldY(float x, float y)
          Screen space to world space conversion for position.
 void setBullet(boolean bullet)
          Set to true to create new bodies as "bullets," which use (slower) continuous collision detection against other moving bodies.
 void setCustomRenderingMethod(java.lang.Object object, java.lang.String methodName)
          For advanced users only.
 void setDensity(float d)
          Set the density used for newly created shapes.
 void setFriction(float f)
          Set the friction used for newly created shapes.
 void setRestitution(float r)
          Set the restitution used for newly created shapes.
 void setSensor(boolean sensor)
          Set to true to create new shapes as sensors.
 void unsetCustomRenderingMethod()
          Clear any custom rendering method that has been set, and revert to the default Box2d debug renderer.
 float worldToScreen(float length)
          World space to screen space conversion for length.
 org.jbox2d.common.Vec2 worldToScreen(float x, float y)
          World space to screen space conversion for position.
 org.jbox2d.common.Vec2 worldToScreen(org.jbox2d.common.Vec2 v)
          World space to screen space conversion for position.
 org.jbox2d.common.Vec2 worldToScreenVector(float wx, float wy)
           
 org.jbox2d.common.Vec2 worldToScreenVector(org.jbox2d.common.Vec2 worldV)
           
 float worldToScreenX(float x, float y)
          World space to screen space conversion for position.
 float worldToScreenY(float x, float y)
          World space to screen space conversion for position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Physics

public Physics(processing.core.PApplet parent,
               float screenW,
               float screenH)
Set up a default physics world. This sets a world bounding box at twice the screen distance from the center, and a hard boundary at the window edges. Uses a default scaling where 1 m = 10 px.

Parameters:
parent -

Physics

public Physics(processing.core.PApplet parent,
               float screenW,
               float screenH,
               float gravX,
               float gravY,
               float screenAABBWidth,
               float screenAABBHeight,
               float borderBoxWidth,
               float borderBoxHeight,
               float pixelsPerMeter)
Set up a physics world.

Parameters:
parent - The PApplet this physics world should use
gravX - The x component of gravity, in meters/sec^2
gravY - The y component of gravity, in meters/sec^2
screenAABBWidth - The world's width, in pixels - should be significantly larger than the area you intend to use
screenAABBHeight - The world's height, in pixels - should be significantly larger than the area you intend to use
borderBoxWidth - The containing box's width - should be smaller than the world width, so that no object can escape
borderBoxHeight - The containing box's height - should be smaller than the world height, so that no object can escape
pixelsPerMeter - Pixels per physical meter
Method Detail

draw

public void draw()
Called automatically by Processing.


setCustomRenderingMethod

public void setCustomRenderingMethod(java.lang.Object object,
                                     java.lang.String methodName)
For advanced users only.

Set a custom rendering method to be called. Use this if the default renderer is not drawing things the way you like, or if you need more flexibility. This will allow a very modular approach to rendering, whereby you can change the entire graphical style on the fly by switching the render function. Hopefully some people a lot more graphically skilled than I am will provide some cool looking functions for this purpose!

The method is set through Java's reflection API, so you may call any method that takes a World object as a parameter. The usual Java way is to force implementation of an interace, but this way you can write things in a simpler manner, within the PDE and without multiple tabs or pure Java. Just pass the object that has the method along with the name of the method.

e.g. if you have the following method defined in your sketch:
 void myDrawMethod(World world) {
   // Do a bunch of stuff
 }
 
then inside either the draw or setup functions you could write:
 setCustomRenderingMethod(this, "myDrawMethod");
to register that function. Use unsetCustomRenderingMethod() to go back to the default renderer.

If you're interested in writing your own renderer, you'll likely need to look at the source code, which you can get to from http://www.jbox2d.org. In particular, the org.jbox2d.dynamics.World file has a drawDebugData() function, which, after some preprocessing, makes some calls out to org.jbox2d.testbed.ProcessingDebugDraw to do the actual drawing. That should give you a place to start from, at least.

Note also that this rendering method has nothing to do with Java2d vs. P3D vs. OpenGL - that choice is made at the beginning of your sketch, and this library won't let you change it! This functionality merely relates to the way bodies and shapes are translated into drawing calls; the drawing calls themselves rely on whatever renderer you chose in your size() function.

Parameters:
object - The object in which your method is defined ('this' should work if the object is defined in a .pde file and not within a class)
methodName - The name of the method (without the parenthesis) to call

unsetCustomRenderingMethod

public void unsetCustomRenderingMethod()
Clear any custom rendering method that has been set, and revert to the default Box2d debug renderer.


defaultDraw

public void defaultDraw(org.jbox2d.dynamics.World world)
Draws the scene using the default render options. Automatically called by the engine unless you have specified your own rendering routine.


getSettings

public org.jbox2d.testbed.TestSettings getSettings()
Get an editable copy of the current TestSettings so that you may change certain aspects of the simulation and display. You do not need to re-set anything after editing these settings, the changes take effect immediately.

The list of useful fields in the TestSettings objects follows:
 public int hz; // "frame" rate of physics simulation - best to leave at 60
 public int iterationCount; // number of constraint iterations - set to 10 normally
 public boolean enableWarmStarting; // makes constraints work better by reusing last results
 public boolean enablePositionCorrection; // leave this on...without it, things turn to mush
 public boolean enableTOI; // enable/disable continuous collision detection
 public boolean drawShapes;
 public boolean drawJoints;
 public boolean drawCoreShapes;
 public boolean drawOBBs;
 public boolean drawCOMs;
 public boolean drawImpulses;
 public boolean drawAABBs;
 public boolean drawPairs;
 public boolean drawContactPoints;
 public boolean drawContactNormals;
 public boolean drawContactForces;
 public boolean drawFrictionForces;
 
Note: the drawing settings only affect the default debug renderer. If you have specified your own renderer, you will have to manually read off and apply these settings if you wish to use them.

Returns:
A reference to the active TestSettings object

createHollowBox

public org.jbox2d.dynamics.Body[] createHollowBox(float centerX,
                                                  float centerY,
                                                  float width,
                                                  float height,
                                                  float thickness)
Create a hollow box of the given screen dimensions.

Parameters:
centerX - Center of box x coordinate (in screen coordinates)
centerY - Center of box y coordinate (in screen coordinates)
width - Width of box (screen scale)
height - Height of box (screen scale)
thickness - Thickness of box edge (screen scale)
Returns:

createRect

public org.jbox2d.dynamics.Body createRect(float x0,
                                           float y0,
                                           float x1,
                                           float y1)
Create a rectangle given by screen coordinates of corners.

Parameters:
x0 -
y0 -
x1 -
y1 -
Returns:

createCircle

public org.jbox2d.dynamics.Body createCircle(float x,
                                             float y,
                                             float r)
Create a circle in screen coordinates

Parameters:
x -
y -
r -
Returns:

createPolygon

public org.jbox2d.dynamics.Body createPolygon(float... vertices)
Create a polygon based on vertices.

Polygons must be: Failure to adhere to any of these restrictions may cause simulation crashes or problems. In particular, if your objects are showing up as static objects instead of dynamic ones, and are not colliding correctly, you have probably not met the clockwise ordering requirement.

This can be called with any number of vertices passed as pairs of interleaved floats, for instance:
 createPolygon(x0,y0,x1,y1,x2,y2,x3,y3);
or
 createPolygon(x0,y0,x1,y1,x2,y2,x3,y3,x4,y4,x5,y5);
or
 float[] xyInterleaved = {x0,y0,x1,y1,x2,y2,x3,y3,x4,y4};
 createPolygon(xyInterleaved);
are all fine.

Parameters:
vertices - Any number of pairs of x,y floats, or an array of the same (screen coordinates)
Returns:

createDistanceJoint

public org.jbox2d.dynamics.joints.DistanceJoint createDistanceJoint(org.jbox2d.dynamics.Body a,
                                                                    org.jbox2d.dynamics.Body b,
                                                                    float xa,
                                                                    float ya,
                                                                    float xb,
                                                                    float yb)
Create a distance (stick) joint between two bodies that holds the specified points at a constant distance.

Once the distance joint is created, it may be turned into a "soft" distance joint by using DistanceJoint::setFrequencyHz(float) to set the frequency to a non-zero value, and using DistanceJoint::setDampingRatio(float) to tune the damping constant.

Distance joints do not support joint limits or motors.

Parameters:
a - First body
b - Second body
xa - x component of anchor point on first body (screen coordinates)
ya - y component of anchor point on first body (screen coordinates)
xb - x component of anchor point on second body (screen coordinates)
yb - y component of anchor point on second body (screen coordinates)
Returns:
Newly created DistanceJoint

createRevoluteJoint

public org.jbox2d.dynamics.joints.RevoluteJoint createRevoluteJoint(org.jbox2d.dynamics.Body a,
                                                                    org.jbox2d.dynamics.Body b,
                                                                    float x,
                                                                    float y)
Create a revolute (pin) joint between the two bodies at the given position.

Joint limits and motors may be set once the joint is created.

Parameters:
a - First body
b - Second body
x - x coordinate of pin joint location (screen coordinates)
y - y coordinate of pin joint location (screen coordinates)
Returns:
Newly created RevoluteJoint

createPrismaticJoint

public org.jbox2d.dynamics.joints.PrismaticJoint createPrismaticJoint(org.jbox2d.dynamics.Body a,
                                                                      org.jbox2d.dynamics.Body b,
                                                                      float dirX,
                                                                      float dirY)
Create a prismatic (piston) joint between two bodies that allows movement in the given direction.

dirX and dirY can be given in screen coordinates or world coordinates, scaling does not matter.

Joint limits and motors may be set once the joint is created.

Parameters:
a - First body
b - Second body
dirX - x component of allowed movement direction
dirY - y component of allowed movement direction
Returns:
Newly created PrismaticJoint

createPulleyJoint

public org.jbox2d.dynamics.joints.PulleyJoint createPulleyJoint(org.jbox2d.dynamics.Body a,
                                                                org.jbox2d.dynamics.Body b,
                                                                float groundAnchorAx,
                                                                float groundAnchorAy,
                                                                float groundAnchorBx,
                                                                float groundAnchorBy,
                                                                float anchorAx,
                                                                float anchorAy,
                                                                float anchorBx,
                                                                float anchorBy,
                                                                float ratio)
Create a pulley joint between the The pulley joint is connected to two bodies and two fixed ground points. The pulley supports a ratio such that: length1 + ratio * length2 = constant Yes, the force transmitted is scaled by the ratio.

The ground anchors are the points where the "rope" touches the pulley, and the anchors are the points on the bodies where the rope is attached.

Joint limits may be set after the joint is created.

Parameters:
a - First body
b - Second body
groundAnchorAx - x coordinate of (fixed) ground anchor for body a, in screen coordinates
groundAnchorAy - y coordinate of (fixed) ground anchor for body a, in screen coordinates
groundAnchorBx - x coordinate of (fixed) ground anchor for body b, in screen coordinates
groundAnchorBy - y coordinate of (fixed) ground anchor for body b, in screen coordinates
anchorAx - x coordinate of body anchor for body a, in screen coordinates
anchorAy - y coordinate of body anchor for body a, in screen coordinates
anchorBx - x coordinate of body anchor for body b, in screen coordinates
anchorBy - y coordinate of body anchor for body b, in screen coordinates
ratio - "Block and tackle" ratio
Returns:
Newly created PulleyJoint

createGearJoint

public org.jbox2d.dynamics.joints.GearJoint createGearJoint(org.jbox2d.dynamics.joints.Joint pj1,
                                                            org.jbox2d.dynamics.joints.Joint pj2,
                                                            float ratio)
Create a gear joint, which binds together two existing revolute or prismatic joints (any combination will work). The provided joints must attach a dynamic body to a static body.

A gear joint is used to connect two joints together. Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motions together: coordinate1 + ratio * coordinate2 = constant The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic joint, then the ratio will have units of length or units of 1/length.
Warning: The revolute and prismatic joints must be attached to fixed bodies (which must be body1 on those joints).

Parameters:
pj1 - First joint (revolute or prismatic)
pj2 - Second joint (revolute or prismatic)
ratio - Gear ratio
Returns:
Newly created GearJoint

setDensity

public void setDensity(float d)
Set the density used for newly created shapes.

Parameters:
d -

getDensity

public float getDensity()
Get the density being used for newly created shapes.

Returns:

setRestitution

public void setRestitution(float r)
Set the restitution used for newly created shapes.

Parameters:
r -

getRestitution

public float getRestitution()
Get the restitution being used for newly created shapes.

Returns:

setFriction

public void setFriction(float f)
Set the friction used for newly created shapes.

Parameters:
f -

getFriction

public float getFriction()
Get the friction being used for newly created shapes.

Returns:

setBullet

public void setBullet(boolean bullet)
Set to true to create new bodies as "bullets," which use (slower) continuous collision detection against other moving bodies.

Warning: continuous collision detection between moving bodies is slow, and should be used sparingly. All bodies use continuous collision detection against static scenery, so for most purposes your bodies should not be marked as bullets.

Parameters:
bullet -

getBullet

public boolean getBullet()
Are newly created bodies being created as bullets?


setSensor

public void setSensor(boolean sensor)
Set to true to create new shapes as sensors. Sensors do not respond to collisions physically, but they generate contact events. This can be useful if you need to check whether a body is in a certain geometrical area.

Parameters:
sensor -

getSensor

public boolean getSensor()
Are newly created shapes being created as sensors?


destroy

public void destroy()
Destroy this world, unregistering it from the PApplet. If this is not called, the world will still be active and simulating, as upon creation it is registered with the PApplet's draw events.


getWorld

public org.jbox2d.dynamics.World getWorld()
Get the current physics world.

Warning: anything involving a World object directly is not strictly supported as part of this Processing library. It is supported as part of JBox2d, however, so there is quite a bit you can do, and you can always ask for help if you run into trouble. Note that all coordinates and vectors in JBox2d proper are in world coordinates, not screen coordinates, so you will likely need to use the screenToWorld and worldToScreen functions to convert back and forth as necessary.

Returns:
The active physics world

getBorder

public org.jbox2d.dynamics.Body[] getBorder()
Get the border Body[] array, or null if the border has been removed.


removeBorder

public void removeBorder()
Remove the solid border if it exists.


removeBody

public void removeBody(org.jbox2d.dynamics.Body b)
Remove a body from the world.


removeJoint

public void removeJoint(org.jbox2d.dynamics.joints.Joint j)
Remove a joint from the world.


applyForce

public void applyForce(org.jbox2d.dynamics.Body b,
                       float fx,
                       float fy)
Apply a force to the body at the center of mass.

Parameters:
b - Body you wish to apply force to
fx - x component of force (in pixel units)
fy - y component of force (in pixel units)

applyForce

public void applyForce(org.jbox2d.dynamics.Body b,
                       org.jbox2d.common.Vec2 f)
Apply a force to the body at the center of mass.

Parameters:
b - Body you wish to apply force to
f - force to apply (in pixel units)

applyForce

public void applyForce(org.jbox2d.dynamics.Body b,
                       float fx,
                       float fy,
                       float pointX,
                       float pointY)
Apply a force to a body at a point.

Parameters:
b - Body you wish to apply force to
fx - x component of force (in pixel units)
fy - y component of force (in pixel units)
pointX - x coordinate of application point (in screen/pixel coordinates)
pointY - y coordinate of application point (in screen/pixel coordinates)

applyForce

public void applyForce(org.jbox2d.dynamics.Body b,
                       org.jbox2d.common.Vec2 f,
                       org.jbox2d.common.Vec2 point)
Apply a force to a body at a point

Parameters:
b - Body you wish to apply force to
f - force to apply (in pixel units)
point - application point (in screen/pixel coordinates)

getPosition

public org.jbox2d.common.Vec2 getPosition(org.jbox2d.dynamics.Body b)
Get the location of the body's origin (screen coordinates) - note that this does not usually correspond to the center of mass position, which may be obtained by calling getCMPosition(Body).

Parameters:
b -
Returns:

getCMPosition

public org.jbox2d.common.Vec2 getCMPosition(org.jbox2d.dynamics.Body b)
Get the center of mass position (screen coordinates)


getAngle

public float getAngle(org.jbox2d.dynamics.Body b)
Get the angle (in radians)


screenToWorldX

public float screenToWorldX(float x,
                            float y)
Screen space to world space conversion for position.


screenToWorldY

public float screenToWorldY(float x,
                            float y)
Screen space to world space conversion for position.


screenToWorld

public org.jbox2d.common.Vec2 screenToWorld(float x,
                                            float y)
Screen space to world space conversion for position.


screenToWorld

public org.jbox2d.common.Vec2 screenToWorld(org.jbox2d.common.Vec2 v)
Screen space to world space conversion for position.


worldToScreenX

public float worldToScreenX(float x,
                            float y)
World space to screen space conversion for position.


worldToScreenY

public float worldToScreenY(float x,
                            float y)
World space to screen space conversion for position.


worldToScreen

public org.jbox2d.common.Vec2 worldToScreen(float x,
                                            float y)
World space to screen space conversion for position.


worldToScreen

public float worldToScreen(float length)
World space to screen space conversion for length.


worldToScreen

public org.jbox2d.common.Vec2 worldToScreen(org.jbox2d.common.Vec2 v)
World space to screen space conversion for position.


screenToWorld

public float screenToWorld(float length)
Screen space to world space conversion for length.


screenToWorldVector

public org.jbox2d.common.Vec2 screenToWorldVector(org.jbox2d.common.Vec2 screenV)

screenToWorldVector

public org.jbox2d.common.Vec2 screenToWorldVector(float sx,
                                                  float sy)

worldToScreenVector

public org.jbox2d.common.Vec2 worldToScreenVector(org.jbox2d.common.Vec2 worldV)

worldToScreenVector

public org.jbox2d.common.Vec2 worldToScreenVector(float wx,
                                                  float wy)