- Object
-
- Joint<T>
-
- Type Parameters:
T
- thePhysicsBody
type
- All Implemented Interfaces:
DataContainer
,Shiftable
,Ownable
- Direct Known Subclasses:
AngleJoint
,DistanceJoint
,FrictionJoint
,MotorJoint
,PinJoint
,PrismaticJoint
,PulleyJoint
,RevoluteJoint
,RopeJoint
,WeldJoint
,WheelJoint
public abstract class Joint<T extends PhysicsBody> extends Object implements Shiftable, DataContainer, Ownable
Represents constrained motion between twoPhysicsBody
s.- Since:
- 1.0.0
- Version:
- 4.0.0
- Author:
- William Bittle
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract Vector2
getAnchor1()
Returns the anchor point on the firstPhysicsBody
in world coordinates.abstract Vector2
getAnchor2()
Returns the anchor point on the secondPhysicsBody
in world coordinates.T
getBody1()
Returns the first body.T
getBody2()
Returns the second body.T
getOtherBody(CollisionBody<?> body)
Returns the body that does not match the given body.Object
getOwner()
Returns the owner for this body.abstract Vector2
getReactionForce(double invdt)
Returns the force applied to thePhysicsBody
s in order to satisfy the constraint in newtons.abstract double
getReactionTorque(double invdt)
Returns the torque applied to thePhysicsBody
s in order to satisfy the constraint in newton-meters.Object
getUserData()
Gets the custom user data.abstract void
initializeConstraints(TimeStep step, Settings settings)
Performs any initialization of the velocity and position constraints.boolean
isActive()
Deprecated.Deprecated in 4.0.0.boolean
isCollisionAllowed()
Returns true if collision between the joinedPhysicsBody
s is allowed.boolean
isEnabled()
Returns true if thisJoint
is enabled.boolean
isOnIsland()
Deprecated.Deprecated in 4.0.0.void
setCollisionAllowed(boolean flag)
Sets whether collision is allowed between the joinedPhysicsBody
s.void
setOnIsland(boolean flag)
Deprecated.Deprecated in 4.0.0.void
setOwner(Object owner)
Sets the owner of this body.void
setUserData(Object userData)
Sets the custom user data to the given data.abstract boolean
solvePositionConstraints(TimeStep step, Settings settings)
Solves the position constraints.abstract void
solveVelocityConstraints(TimeStep step, Settings settings)
Solves the velocity constraints.String
toString()
-
-
-
Constructor Detail
-
Joint
public Joint(T body1, T body2)
Optional constructor.Assumes that the joined bodies do not participate in collision detection and resolution.
- Parameters:
body1
- the firstPhysicsBody
body2
- the secondPhysicsBody
- Throws:
NullPointerException
- if body1 or body2 is null
-
Joint
public Joint(T body1, T body2, boolean collisionAllowed)
Full constructor.- Parameters:
body1
- the firstPhysicsBody
body2
- the secondPhysicsBody
collisionAllowed
- true if the joinedPhysicsBody
s can take part in collision detection- Throws:
NullPointerException
- if body1 or body2 is null
-
-
Method Detail
-
initializeConstraints
public abstract void initializeConstraints(TimeStep step, Settings settings)
Performs any initialization of the velocity and position constraints.- Parameters:
step
- the time step informationsettings
- the current world settings
-
solveVelocityConstraints
public abstract void solveVelocityConstraints(TimeStep step, Settings settings)
Solves the velocity constraints.- Parameters:
step
- the time step informationsettings
- the current world settings
-
solvePositionConstraints
public abstract boolean solvePositionConstraints(TimeStep step, Settings settings)
Solves the position constraints.- Parameters:
step
- the time step informationsettings
- the current world settings- Returns:
- boolean true if the position constraints were solved
-
getBody1
public T getBody1()
Returns the first body.- Returns:
- T
-
getBody2
public T getBody2()
Returns the second body.- Returns:
- T
-
getOtherBody
public T getOtherBody(CollisionBody<?> body)
Returns the body that does not match the given body.If the given body is neither body1 or body2, null is returned.
- Parameters:
body
- the body- Returns:
- T
-
getAnchor1
public abstract Vector2 getAnchor1()
Returns the anchor point on the firstPhysicsBody
in world coordinates.- Returns:
Vector2
-
getAnchor2
public abstract Vector2 getAnchor2()
Returns the anchor point on the secondPhysicsBody
in world coordinates.- Returns:
Vector2
-
getReactionForce
public abstract Vector2 getReactionForce(double invdt)
Returns the force applied to thePhysicsBody
s in order to satisfy the constraint in newtons.- Parameters:
invdt
- the inverse delta time- Returns:
Vector2
-
getReactionTorque
public abstract double getReactionTorque(double invdt)
Returns the torque applied to thePhysicsBody
s in order to satisfy the constraint in newton-meters.- Parameters:
invdt
- the inverse delta time- Returns:
- double
-
isActive
@Deprecated public boolean isActive()
Deprecated.Deprecated in 4.0.0. Use the isEnabled method insteadReturns true if thisJoint
is active.A joint is only active if both joined
PhysicsBody
s are active.- Returns:
- boolean
-
isEnabled
public boolean isEnabled()
Returns true if thisJoint
is enabled.A joint is only enabled if both joined
PhysicsBody
s are enabled.- Returns:
- boolean
-
isCollisionAllowed
public boolean isCollisionAllowed()
Returns true if collision between the joinedPhysicsBody
s is allowed.- Returns:
- boolean
-
setCollisionAllowed
public void setCollisionAllowed(boolean flag)
Sets whether collision is allowed between the joinedPhysicsBody
s.- Parameters:
flag
- true if collisions are allowed
-
getUserData
public Object getUserData()
Description copied from interface:DataContainer
Gets the custom user data.- Specified by:
getUserData
in interfaceDataContainer
- Returns:
- Object will return null if not set
-
setUserData
public void setUserData(Object userData)
Description copied from interface:DataContainer
Sets the custom user data to the given data.- Specified by:
setUserData
in interfaceDataContainer
- Parameters:
userData
- the user data
-
isOnIsland
@Deprecated public boolean isOnIsland()
Deprecated.Deprecated in 4.0.0. No replacement needed.Returns true if this joint is on an island.- Returns:
- boolean
-
setOnIsland
@Deprecated public void setOnIsland(boolean flag)
Deprecated.Deprecated in 4.0.0. No replacement needed.Flags this joint as being on an island.- Parameters:
flag
- true if this joint is on an island
-
getOwner
public Object getOwner()
Description copied from interface:Ownable
Returns the owner for this body.
-
-