Module org.dyn4j
Package org.dyn4j.dynamics.joint
Class AbstractPairedBodyJoint<T extends PhysicsBody>
- Object
-
- AbstractJoint<T>
-
- AbstractPairedBodyJoint<T>
-
- Type Parameters:
T
- thePhysicsBody
type
- All Implemented Interfaces:
DataContainer
,Joint<T>
,PairedBodyJoint<T>
,Shiftable
,Ownable
- Direct Known Subclasses:
AngleJoint
,DistanceJoint
,FrictionJoint
,MotorJoint
,PrismaticJoint
,PulleyJoint
,RevoluteJoint
,WeldJoint
,WheelJoint
public abstract class AbstractPairedBodyJoint<T extends PhysicsBody> extends AbstractJoint<T> implements PairedBodyJoint<T>, Joint<T>, Shiftable, DataContainer, Ownable
Represents an abstract implementation of constrained motion between twoPhysicsBody
s.- Since:
- 5.0.0
- Version:
- 5.0.0
- Author:
- William Bittle
-
-
Field Summary
Fields Modifier and Type Field Description protected T
body1
The first linked bodyprotected T
body2
The second linked body-
Fields inherited from class AbstractJoint
bodies, collisionAllowed, owner, userData
-
Fields inherited from interface Joint
SPRING_MODE_FREQUENCY, SPRING_MODE_STIFFNESS
-
-
Constructor Summary
Constructors Constructor Description AbstractPairedBodyJoint(T body1, T body2)
Optional constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
getBody(int i)
Returns the body at the given index.T
getBody1()
Returns the first body.T
getBody2()
Returns the second body.int
getBodyCount()
Returns the number of bodies involved in this joint.T
getOtherBody(CollisionBody<?> body)
Returns the body that does not match the given body.protected double
getReducedInertia()
Returns the reduced inertia of this pair of bodies.protected double
getReducedMass()
Returns the reduced mass of this pair of bodies.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.-
Methods inherited from class AbstractJoint
getBodies, getBodyIterator, getConstraintImpulseMixing, getErrorReductionParameter, getFrequency, getNaturalFrequency, getNaturalFrequency, getOwner, getSpringDampingCoefficient, getSpringStiffness, getUserData, isCollisionAllowed, setOwner, setUserData, toString
-
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface DataContainer
getUserData, setUserData
-
Methods inherited from interface Joint
getBodies, getBodyIterator, getReactionForce, getReactionTorque, initializeConstraints, isCollisionAllowed, solvePositionConstraints, solveVelocityConstraints
-
-
-
-
Field Detail
-
body1
protected final T extends PhysicsBody body1
The first linked body
-
body2
protected final T extends PhysicsBody body2
The second linked body
-
-
Constructor Detail
-
AbstractPairedBodyJoint
public AbstractPairedBodyJoint(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 nullIllegalArgumentException
- if body1 and body2 are the same object reference
-
-
Method Detail
-
getReducedMass
protected final double getReducedMass()
Returns the reduced mass of this pair of bodies.The reduced mass is used to solve spring/damper problems as a single body rather than as a system of two bodies.
- Returns:
- double
-
getReducedInertia
protected final double getReducedInertia()
Returns the reduced inertia of this pair of bodies.- Returns:
- double
- See Also:
getReducedMass()
-
isEnabled
public final boolean isEnabled()
Description copied from interface:Joint
Returns true if thisJoint
is enabled.A joint is only enabled if all joined
PhysicsBody
s are enabled.- Specified by:
isEnabled
in interfaceJoint<T extends PhysicsBody>
- Overrides:
isEnabled
in classAbstractJoint<T extends PhysicsBody>
- Returns:
- boolean
-
getBody
public final T getBody(int i)
Description copied from interface:Joint
Returns the body at the given index.- Specified by:
getBody
in interfaceJoint<T extends PhysicsBody>
- Overrides:
getBody
in classAbstractJoint<T extends PhysicsBody>
- Parameters:
i
- the index- Returns:
- T
-
getBodyCount
public final int getBodyCount()
Description copied from interface:Joint
Returns the number of bodies involved in this joint.- Specified by:
getBodyCount
in interfaceJoint<T extends PhysicsBody>
- Overrides:
getBodyCount
in classAbstractJoint<T extends PhysicsBody>
- Returns:
- int
-
isMember
public final boolean isMember(CollisionBody<?> body)
Description copied from interface:Joint
Returns true if the given body is a member of this joint.- Specified by:
isMember
in interfaceJoint<T extends PhysicsBody>
- Overrides:
isMember
in classAbstractJoint<T extends PhysicsBody>
- Parameters:
body
- the body- Returns:
- boolean
-
setCollisionAllowed
public final void setCollisionAllowed(boolean flag)
Description copied from interface:Joint
Sets whether collision is allowed between the joinedPhysicsBody
s.- Specified by:
setCollisionAllowed
in interfaceJoint<T extends PhysicsBody>
- Overrides:
setCollisionAllowed
in classAbstractJoint<T extends PhysicsBody>
- Parameters:
flag
- true if collisions are allowed
-
getOtherBody
public final T getOtherBody(CollisionBody<?> body)
Description copied from interface:PairedBodyJoint
Returns the body that does not match the given body.If the given body is neither body1 or body2, null is returned.
- Specified by:
getOtherBody
in interfacePairedBodyJoint<T extends PhysicsBody>
- Parameters:
body
- the body- Returns:
- T
-
getBody1
public final T getBody1()
Description copied from interface:PairedBodyJoint
Returns the first body.- Specified by:
getBody1
in interfacePairedBodyJoint<T extends PhysicsBody>
- Returns:
- T
-
getBody2
public final T getBody2()
Description copied from interface:PairedBodyJoint
Returns the second body.- Specified by:
getBody2
in interfacePairedBodyJoint<T extends PhysicsBody>
- Returns:
- T
-
-