-
- Type Parameters:
T
- thePhysicsBody
type
- All Implemented Interfaces:
DataContainer
,Shiftable
,Ownable
public class WeldJoint<T extends PhysicsBody> extends Joint<T> implements Shiftable, DataContainer
Implementation of a weld joint.A weld joint joins two bodies together as if they were a single body with two fixtures. Both their relative linear and angular motion are constrained to keep them attached to each other. The system as a whole can rotate and translate freely.
Using a frequency greater than zero allows the joint to function as a torsion spring about the anchor point. A good starting point is a frequency of 8.0 and damping ratio of 0.3 then adjust as necessary.
- Since:
- 1.0.0
- Version:
- 4.0.0
- Author:
- William Bittle
- See Also:
- Documentation, Weld Constraint
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Vector2
getAnchor1()
Returns the anchor point on the firstPhysicsBody
in world coordinates.Vector2
getAnchor2()
Returns the anchor point on the secondPhysicsBody
in world coordinates.double
getDampingRatio()
Returns the damping ratio.double
getFrequency()
Returns the spring frequency.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.double
getReferenceAngle()
Returns the reference angle.void
initializeConstraints(TimeStep step, Settings settings)
Performs any initialization of the velocity and position constraints.boolean
isSpring()
Deprecated.Deprecated in 4.0.0.boolean
isSpringDamper()
Deprecated.Deprecated in 4.0.0.boolean
isSpringDamperEnabled()
Returns true if this distance joint is a spring distance joint with damping.boolean
isSpringEnabled()
Returns true if this distance joint is a spring distance joint.void
setDampingRatio(double dampingRatio)
Sets the damping ratio.void
setFrequency(double frequency)
Sets the spring frequency.void
setReferenceAngle(double angle)
Sets the reference angle.void
shift(Vector2 shift)
Translates the object to match the given coordinate shift.boolean
solvePositionConstraints(TimeStep step, Settings settings)
Solves the position constraints.void
solveVelocityConstraints(TimeStep step, Settings settings)
Solves the velocity constraints.String
toString()
-
Methods inherited from class Joint
getBody1, getBody2, getOtherBody, getOwner, getUserData, isActive, isCollisionAllowed, isEnabled, isOnIsland, setCollisionAllowed, setOnIsland, setOwner, setUserData
-
Methods inherited from interface DataContainer
getUserData, setUserData
-
-
-
-
Constructor Detail
-
WeldJoint
public WeldJoint(T body1, T body2, Vector2 anchor)
Minimal constructor.- Parameters:
body1
- the firstPhysicsBody
body2
- the secondPhysicsBody
anchor
- the anchor point in world coordinates- Throws:
NullPointerException
- if body1, body2, or anchor is nullIllegalArgumentException
- if body1 == body2
-
-
Method Detail
-
toString
public String toString()
- Overrides:
toString
in classJoint<T extends PhysicsBody>
-
initializeConstraints
public void initializeConstraints(TimeStep step, Settings settings)
Description copied from class:Joint
Performs any initialization of the velocity and position constraints.- Specified by:
initializeConstraints
in classJoint<T extends PhysicsBody>
- Parameters:
step
- the time step informationsettings
- the current world settings
-
solveVelocityConstraints
public void solveVelocityConstraints(TimeStep step, Settings settings)
Description copied from class:Joint
Solves the velocity constraints.- Specified by:
solveVelocityConstraints
in classJoint<T extends PhysicsBody>
- Parameters:
step
- the time step informationsettings
- the current world settings
-
solvePositionConstraints
public boolean solvePositionConstraints(TimeStep step, Settings settings)
Description copied from class:Joint
Solves the position constraints.- Specified by:
solvePositionConstraints
in classJoint<T extends PhysicsBody>
- Parameters:
step
- the time step informationsettings
- the current world settings- Returns:
- boolean true if the position constraints were solved
-
getAnchor1
public Vector2 getAnchor1()
Description copied from class:Joint
Returns the anchor point on the firstPhysicsBody
in world coordinates.- Specified by:
getAnchor1
in classJoint<T extends PhysicsBody>
- Returns:
Vector2
-
getAnchor2
public Vector2 getAnchor2()
Description copied from class:Joint
Returns the anchor point on the secondPhysicsBody
in world coordinates.- Specified by:
getAnchor2
in classJoint<T extends PhysicsBody>
- Returns:
Vector2
-
getReactionForce
public Vector2 getReactionForce(double invdt)
Description copied from class:Joint
Returns the force applied to thePhysicsBody
s in order to satisfy the constraint in newtons.- Specified by:
getReactionForce
in classJoint<T extends PhysicsBody>
- Parameters:
invdt
- the inverse delta time- Returns:
Vector2
-
getReactionTorque
public double getReactionTorque(double invdt)
Description copied from class:Joint
Returns the torque applied to thePhysicsBody
s in order to satisfy the constraint in newton-meters.- Specified by:
getReactionTorque
in classJoint<T extends PhysicsBody>
- Parameters:
invdt
- the inverse delta time- Returns:
- double
-
shift
public void shift(Vector2 shift)
Description copied from interface:Shiftable
Translates the object to match the given coordinate shift.
-
isSpring
@Deprecated public boolean isSpring()
Deprecated.Deprecated in 4.0.0. Use theisSpringEnabled()
method instead.Returns true if this distance joint is a spring distance joint.- Returns:
- boolean
- Since:
- 3.0.1
-
isSpringDamper
@Deprecated public boolean isSpringDamper()
Deprecated.Deprecated in 4.0.0. Use theisSpringDamperEnabled()
method instead.Returns true if this distance joint is a spring distance joint with damping.- Returns:
- boolean
- Since:
- 3.0.1
-
isSpringEnabled
public boolean isSpringEnabled()
Returns true if this distance joint is a spring distance joint.- Returns:
- boolean
- Since:
- 4.0.0
-
isSpringDamperEnabled
public boolean isSpringDamperEnabled()
Returns true if this distance joint is a spring distance joint with damping.- Returns:
- boolean
- Since:
- 4.0.0
-
getDampingRatio
public double getDampingRatio()
Returns the damping ratio.- Returns:
- double
- Since:
- 3.0.1
-
setDampingRatio
public void setDampingRatio(double dampingRatio)
Sets the damping ratio.Larger values reduce the oscillation of the spring.
- Parameters:
dampingRatio
- the damping ratio; in the range [0, 1]- Throws:
IllegalArgumentException
- if damping ration is less than zero or greater than 1- Since:
- 3.0.1
-
getFrequency
public double getFrequency()
Returns the spring frequency.- Returns:
- double
- Since:
- 3.0.1
-
setFrequency
public void setFrequency(double frequency)
Sets the spring frequency.Larger values increase the stiffness of the spring.
- Parameters:
frequency
- the spring frequency in hz; must be greater than or equal to zero- Throws:
IllegalArgumentException
- if frequency is less than zero- Since:
- 3.0.1
-
getReferenceAngle
public double getReferenceAngle()
Returns the reference angle.The reference angle is the angle calculated when the joint was created from the two joined bodies. The reference angle is the angular difference between the bodies.
- Returns:
- double
- Since:
- 3.0.1
-
setReferenceAngle
public void setReferenceAngle(double angle)
Sets the reference angle.This method can be used to set the reference angle to override the computed reference angle from the constructor. This is useful in recreating the joint from a current state.
- Parameters:
angle
- the reference angle in radians- Since:
- 3.0.1
- See Also:
getReferenceAngle()
-
-