-
- Type Parameters:
T
- thePhysicsBody
type
- All Superinterfaces:
DataContainer
,Ownable
,Shiftable
- All Known Subinterfaces:
PairedBodyJoint<T>
,SingleBodyJoint<T>
- All Known Implementing Classes:
AbstractJoint
,AbstractPairedBodyJoint
,AbstractSingleBodyJoint
,AngleJoint
,DistanceJoint
,FrictionJoint
,MotorJoint
,PinJoint
,PrismaticJoint
,PulleyJoint
,RevoluteJoint
,WeldJoint
,WheelJoint
public interface Joint<T extends PhysicsBody> extends Shiftable, DataContainer, Ownable
Represents constrained motion betweenPhysicsBody
s.- Since:
- 5.0.0
- Version:
- 5.0.0
- Author:
- William Bittle
-
-
Field Summary
Fields Modifier and Type Field Description static int
SPRING_MODE_FREQUENCY
Mode indicating that the current frequency should be used to calculate the spring stiffnessstatic int
SPRING_MODE_STIFFNESS
Mode indicating that the current stiffness should be used to calculate the spring frequency
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<T>
getBodies()
Returns an unmodifiable list of bodies involved in this joint.T
getBody(int index)
Returns the body at the given index.int
getBodyCount()
Returns the number of bodies involved in this joint.Iterator<T>
getBodyIterator()
Returns an iterator for the bodies involved in this joint.Vector2
getReactionForce(double invdt)
Returns the force applied to thePhysicsBody
s in order to satisfy the constraint in newtons.double
getReactionTorque(double invdt)
Returns the torque applied to thePhysicsBody
s in order to satisfy the constraint in newton-meters.void
initializeConstraints(TimeStep step, Settings settings)
Performs any initialization of the velocity and position constraints.boolean
isCollisionAllowed()
Returns true if collision between the joinedPhysicsBody
s is allowed.boolean
isEnabled()
Returns true if thisJoint
is enabled.boolean
isMember(CollisionBody<?> body)
Returns true if the given body is a member of this joint.void
setCollisionAllowed(boolean flag)
Sets whether collision is allowed between the joinedPhysicsBody
s.boolean
solvePositionConstraints(TimeStep step, Settings settings)
Solves the position constraints.void
solveVelocityConstraints(TimeStep step, Settings settings)
Solves the velocity constraints.-
Methods inherited from interface DataContainer
getUserData, setUserData
-
-
-
-
Field Detail
-
SPRING_MODE_FREQUENCY
static final int SPRING_MODE_FREQUENCY
Mode indicating that the current frequency should be used to calculate the spring stiffness- See Also:
- Constant Field Values
-
SPRING_MODE_STIFFNESS
static final int SPRING_MODE_STIFFNESS
Mode indicating that the current stiffness should be used to calculate the spring frequency- See Also:
- Constant Field Values
-
-
Method Detail
-
getBodies
List<T> getBodies()
Returns an unmodifiable list of bodies involved in this joint.- Returns:
- List<T>
-
getBodyCount
int getBodyCount()
Returns the number of bodies involved in this joint.- Returns:
- int
-
getBody
T getBody(int index)
Returns the body at the given index.- Parameters:
index
- the index- Returns:
- T
- Throws:
IndexOutOfBoundsException
- when index is greater than or equal togetBodyCount()
-
getBodyIterator
Iterator<T> getBodyIterator()
Returns an iterator for the bodies involved in this joint.NOTE: The iterator is read-only and will throw if methods like
remove
are used.- Returns:
- Iterator<T>
-
isMember
boolean isMember(CollisionBody<?> body)
Returns true if the given body is a member of this joint.- Parameters:
body
- the body- Returns:
- boolean
-
initializeConstraints
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
void solveVelocityConstraints(TimeStep step, Settings settings)
Solves the velocity constraints.- Parameters:
step
- the time step informationsettings
- the current world settings
-
solvePositionConstraints
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
-
getReactionForce
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
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
-
isEnabled
boolean isEnabled()
Returns true if thisJoint
is enabled.A joint is only enabled if all joined
PhysicsBody
s are enabled.- Returns:
- boolean
-
isCollisionAllowed
boolean isCollisionAllowed()
Returns true if collision between the joinedPhysicsBody
s is allowed.- Returns:
- boolean
-
setCollisionAllowed
void setCollisionAllowed(boolean flag)
Sets whether collision is allowed between the joinedPhysicsBody
s.- Parameters:
flag
- true if collisions are allowed
-
-