org.jbox2d.collision.shapes
Class EdgeShape

java.lang.Object
  extended by org.jbox2d.collision.shapes.Shape
      extended by org.jbox2d.collision.shapes.EdgeShape
All Implemented Interfaces:
SupportsGenericDistance

public class EdgeShape
extends Shape
implements SupportsGenericDistance

An edge shape. Create using Body.createShape(ShapeDef) with an EdgeChainDef, not the constructor here.

Author:
daniel
See Also:
Body.createShape(ShapeDef), EdgeChainDef

Field Summary
 
Fields inherited from class org.jbox2d.collision.shapes.Shape
m_body, m_density, m_filter, m_friction, m_isSensor, m_next, m_proxyId, m_restitution, m_sweepRadius, m_type, m_userData, uid
 
Constructor Summary
EdgeShape(Vec2 v1, Vec2 v2, ShapeDef def)
          Don't use this.
 
Method Summary
 void computeAABB(AABB aabb, XForm transform)
          Given a transform, compute the associated axis aligned bounding box for this shape.
 void computeMass(MassData massData)
          Compute the mass properties of this shape using its dimensions and density.
 void computeSweptAABB(AABB aabb, XForm transform1, XForm transform2)
          Given two transforms, compute the associated swept axis aligned bounding box for this shape.
 boolean corner1IsConvex()
           
 boolean corner2IsConvex()
           
 Vec2 getCoreVertex1()
          "Core" vertex with TOI slop for b2Distance functions
 Vec2 getCoreVertex2()
          "Core" vertex with TOI slop for b2Distance functions
 Vec2 getCorner1Vector()
           
 Vec2 getCorner2Vector()
           
 Vec2 getDirectionVector()
          Parallel unit vector, pointing from vertex1 to vertex2
 void getFirstVertexToOut(XForm xf, Vec2 out)
           
 float getLength()
          Linear distance from vertex1 to vertex2
 EdgeShape getNextEdge()
          Get the next edge in the chain.
 Vec2 getNormalVector()
          Perpendecular unit vector point, pointing from the solid side to the empty side.
 EdgeShape getPrevEdge()
          Get the previous edge in the chain.
 Vec2 getVertex1()
          Local position of vertex in parent body
 Vec2 getVertex2()
          Local position of vertex in parent body
 void setNextEdge(EdgeShape edge, Vec2 core, Vec2 cornerDir, boolean convex)
           
 void setPrevEdge(EdgeShape edge, Vec2 core, Vec2 cornerDir, boolean convex)
           
 void support(Vec2 dest, XForm xf, Vec2 d)
           
 boolean testPoint(XForm transform, Vec2 p)
          Test a point for containment in this shape.
 void updateSweepRadius(Vec2 center)
          Internal
 
Methods inherited from class org.jbox2d.collision.shapes.Shape
create, createProxy, destroy, destroyProxy, destructor, getBody, getFilterData, getFriction, getNext, getRestitution, getSweepRadius, getType, getUserData, isSensor, refilterProxy, setFilterData, setFriction, setRestitution, setUserData, synchronize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EdgeShape

public EdgeShape(Vec2 v1,
                 Vec2 v2,
                 ShapeDef def)
Don't use this. Instead create using Body.createShape(ShapeDef) with an EdgeChainDef, not the constructor here.

Parameters:
v1 -
v2 -
def -
See Also:
Body.createShape(ShapeDef), EdgeChainDef
Method Detail

updateSweepRadius

public void updateSweepRadius(Vec2 center)
Description copied from class: Shape
Internal

Specified by:
updateSweepRadius in class Shape
See Also:
Shape.updateSweepRadius(Vec2)

testPoint

public boolean testPoint(XForm transform,
                         Vec2 p)
Description copied from class: Shape
Test a point for containment in this shape. This only works for convex shapes.

Specified by:
testPoint in class Shape
Parameters:
transform - the shape world transform.
p - a point in world coordinates.
Returns:
true if the point is within the shape
See Also:
Shape.testPoint(XForm, Vec2)

computeAABB

public void computeAABB(AABB aabb,
                        XForm transform)
Description copied from class: Shape
Given a transform, compute the associated axis aligned bounding box for this shape.

Specified by:
computeAABB in class Shape
Parameters:
aabb - returns the axis aligned box.
transform - the world transform of the shape.
See Also:
Shape.computeAABB(AABB, XForm)

computeSweptAABB

public void computeSweptAABB(AABB aabb,
                             XForm transform1,
                             XForm transform2)
Description copied from class: Shape
Given two transforms, compute the associated swept axis aligned bounding box for this shape.

Specified by:
computeSweptAABB in class Shape
Parameters:
aabb - returns the axis aligned box. (return parameter)
transform1 - the starting shape world transform.
transform2 - the ending shape world transform.
See Also:
Shape.computeSweptAABB(AABB, XForm, XForm)

computeMass

public void computeMass(MassData massData)
Description copied from class: Shape
Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin, not the centroid.

Specified by:
computeMass in class Shape
Parameters:
massData - returns the mass data for this shape. (return parameter)
See Also:
Shape.computeMass(MassData)

support

public void support(Vec2 dest,
                    XForm xf,
                    Vec2 d)
Specified by:
support in interface SupportsGenericDistance
See Also:
SupportsGenericDistance.support(Vec2, XForm, Vec2)

setPrevEdge

public void setPrevEdge(EdgeShape edge,
                        Vec2 core,
                        Vec2 cornerDir,
                        boolean convex)

setNextEdge

public void setNextEdge(EdgeShape edge,
                        Vec2 core,
                        Vec2 cornerDir,
                        boolean convex)

getLength

public float getLength()
Linear distance from vertex1 to vertex2


getVertex1

public Vec2 getVertex1()
Local position of vertex in parent body


getVertex2

public Vec2 getVertex2()
Local position of vertex in parent body


getCoreVertex1

public Vec2 getCoreVertex1()
"Core" vertex with TOI slop for b2Distance functions


getCoreVertex2

public Vec2 getCoreVertex2()
"Core" vertex with TOI slop for b2Distance functions


getNormalVector

public Vec2 getNormalVector()
Perpendecular unit vector point, pointing from the solid side to the empty side.


getDirectionVector

public Vec2 getDirectionVector()
Parallel unit vector, pointing from vertex1 to vertex2


getCorner1Vector

public Vec2 getCorner1Vector()

getCorner2Vector

public Vec2 getCorner2Vector()

getNextEdge

public EdgeShape getNextEdge()
Get the next edge in the chain.


getPrevEdge

public EdgeShape getPrevEdge()
Get the previous edge in the chain.


getFirstVertexToOut

public void getFirstVertexToOut(XForm xf,
                                Vec2 out)
Specified by:
getFirstVertexToOut in interface SupportsGenericDistance
See Also:
SupportsGenericDistance.getFirstVertexToOut(XForm, Vec2)

corner1IsConvex

public boolean corner1IsConvex()

corner2IsConvex

public boolean corner2IsConvex()