- Object
-
- AbstractJoint<T>
-
- AbstractPairedBodyJoint<T>
-
- PrismaticJoint<T>
-
- Type Parameters:
T
- thePhysicsBody
type
- All Implemented Interfaces:
DataContainer
,Joint<T>
,LinearLimitsJoint
,LinearMotorJoint
,LinearSpringJoint
,PairedBodyJoint<T>
,Shiftable
,Ownable
public class PrismaticJoint<T extends PhysicsBody> extends AbstractPairedBodyJoint<T> implements LinearLimitsJoint, LinearMotorJoint, LinearSpringJoint, PairedBodyJoint<T>, Joint<T>, Shiftable, DataContainer, Ownable
Implementation of a prismatic joint.A prismatic joint constrains the linear motion of two bodies along an axis and prevents relative rotation. The whole system can rotate and translate freely.
The initial relative rotation of the bodies will remain unchanged unless updated by calling
setReferenceAngle(double)
method. The bodies are not required to be aligned in any particular way.The world space axis is fixed to the first body. This means that when the first body rotates, the axis will rotate with it. The axis represents the allowed linear motion between the bodies.
The world space anchor point can be any point but is typically a point on the axis of allowed motion, usually the world center of either of the joined bodies. The anchor point is used to track the separation of the bodies from the allowed axis of motion when drift occurs in the velocity solver.
This joint also supports a linear spring, but is disabled by default. By default the frequency and damping ratio are set to 8.0 and 0.0 respectively. You can enable/disable the various spring-damper features using
setSpringEnabled(boolean)
,setSpringDamperEnabled(boolean)
,setMaximumSpringForceEnabled(boolean)
methods. As with all spring -damper enabled joints, the spring must be enabled for the damper to be applied. Also note that when the damper is disabled, the spring still experiences "damping" aka energy loss - this is a side effect of the solver and intended behavior.This joint has an added spring feature called the rest offset. Similar to the rest distance in the distance joint, but only applied when the spring is enabled. When you build the joint, the default distance between the two bodies is their initial distance. You can use the
setSpringRestOffset(double)
to raise or lower the distance between the bodies when the spring is active.The joint also supports upper and lower limits. The limits represent the maximum displacement from the anchor point along the given axis. This means that the limits are typically negative for the lower limit and positive for the upper limit. The limits are solved relative to the given axis's direction. The limits can be enabled separately using
setLowerLimitEnabled(boolean)
andsetUpperLimitEnabled(boolean)
. This also means that the limits are relative to the initial starting position of the bodies.This joint also supports a motor. The motor is a linear motor along the axis. The motor speed can be positive or negative to indicate motion along or opposite the axis direction. The maximum motor force must be greater than zero for the motor to apply any motion. The motor must be enabled using
setMotorEnabled(boolean)
.NOTE: The spring-damper and motor can be enabled at the same time, but since they operate on the same degree of freedom, the feature that has the highest maximum force will win. It's recommended to only use one or the other.
NOTE: In versions of dyn4j before 5.0.0, the body arguments in the constructor were reversed. It was changed to accept the frame first, then the wheel to make things more natural.
- Since:
- 1.0.0
- Version:
- 5.0.0
- Author:
- William Bittle
- See Also:
- Documentation, Prismatic Constraint
-
-
Field Summary
Fields Modifier and Type Field Description protected Vector2
localAnchor1
The local anchor point on the firstPhysicsBody
protected Vector2
localAnchor2
The local anchor point on the secondPhysicsBody
protected double
lowerLimit
the lower limit in metersprotected boolean
lowerLimitEnabled
True if the lower limit is enabledprotected double
maximumMotorForce
The maximum force the motor can apply in newtonsprotected boolean
maximumMotorForceEnabled
True if the motor force should be limitedprotected boolean
motorEnabled
Whether the motor is enabled or notprotected double
motorSpeed
The target velocity in meters / secondprotected double
referenceAngle
The initial angle between the twoPhysicsBody
sprotected boolean
springDamperEnabled
True if the spring-damper is enabledprotected double
springDampingRatio
The damping ratioprotected boolean
springEnabled
True if the spring is enabledprotected double
springFrequency
The oscillation frequency in hzprotected double
springMaximumForce
The maximum force the spring will applyprotected boolean
springMaximumForceEnabled
True if the spring maximum force is enabledprotected int
springMode
The spring mode (frequency or stiffness)protected double
springRestOffset
The rest offset of the springprotected double
springStiffness
The stiffness of the springprotected double
upperLimit
the upper limit in metersprotected boolean
upperLimitEnabled
True if the upper limit is enabledprotected Vector2
xAxis
The axis representing the allowed line of motionprotected Vector2
yAxis
The perpendicular axis of the line of motion-
Fields inherited from class AbstractPairedBodyJoint
body1, body2
-
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 PrismaticJoint(T body1, T body2, Vector2 anchor, Vector2 axis)
Minimal constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector2
getAnchor1()
The original anchor point on body1 in world space.Vector2
getAnchor2()
The original anchor point on body2 in world space.Vector2
getAxis()
Returns the axis in which the joint is allowed move along in world coordinates.double
getLinearSpeed()
Returns the current joint speed.double
getLinearTranslation()
Returns the current joint translation.double
getLowerLimit()
Returns the lower limit in meters.double
getMaximumMotorForce()
Returns the maximum force the motor can apply to the joint to achieve the target speed.double
getMaximumSpringForce()
Returns the maximum spring force that will be applied.double
getMotorForce(double invdt)
Returns the applied motor force.double
getMotorSpeed()
Returns the target motor speed in meters / second.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.double
getSpringDampingRatio()
Returns the damping ratio for the spring's damper.double
getSpringForce(double invdt)
Returns the force in netwons applied by the spring in the last timestep.double
getSpringFrequency()
Returns the spring frequency.int
getSpringMode()
Returns the current spring mode.double
getSpringRestOffset()
Returns the spring's rest offset.double
getSpringStiffness()
Returns the spring stiffness.double
getUpperLimit()
Returns the upper limit in meters.void
initializeConstraints(TimeStep step, Settings settings)
Performs any initialization of the velocity and position constraints.boolean
isLowerLimitEnabled()
Returns true if the lower limit is enabled.boolean
isMaximumMotorForceEnabled()
Returns true if the maximum motor force is enabled.boolean
isMaximumSpringForceEnabled()
Returns true if the spring force is limited to the maximum.boolean
isMotorEnabled()
Returns true if the motor is enabled.boolean
isSpringDamperEnabled()
Returns true if the damper is enabled for the spring.boolean
isSpringEnabled()
Returns true if the spring is enabled.boolean
isUpperLimitEnabled()
Returns true if the upper limit is enabled.void
setLimits(double limit)
Sets both the lower and upper limits to the given limit.void
setLimits(double lowerLimit, double upperLimit)
Sets both the lower and upper limits.void
setLimitsEnabled(boolean flag)
Enables or disables both the lower and upper limits.void
setLimitsEnabled(double limit)
Sets both the lower and upper limits to the given limit and enables both.void
setLimitsEnabled(double lowerLimit, double upperLimit)
Sets both the lower and upper limits and enables both.void
setLowerLimit(double lowerLimit)
Sets the lower limit in meters.void
setLowerLimitEnabled(boolean flag)
Sets whether the lower limit is enabled.void
setMaximumMotorForce(double maximumMotorForce)
Sets the maximum force the motor can apply to the joint to achieve the target speed.void
setMaximumMotorForceEnabled(boolean enabled)
Sets whether the maximum motor force is enabled.void
setMaximumSpringForce(double maximum)
Sets the maximum force the spring can apply.void
setMaximumSpringForceEnabled(boolean enabled)
Sets whether the spring force is limited to the maximum.void
setMotorEnabled(boolean motorEnabled)
Enables or disables the motor.void
setMotorSpeed(double motorSpeed)
Sets the target motor speed.void
setReferenceAngle(double angle)
Sets the reference angle.void
setSpringDamperEnabled(boolean enabled)
Sets whether the spring's damper is enabled or not.void
setSpringDampingRatio(double dampingRatio)
Sets the damping ratio.void
setSpringEnabled(boolean enabled)
Sets whether the spring is enabled or not.void
setSpringFrequency(double frequency)
Sets the spring frequency.void
setSpringRestOffset(double offset)
Set's the spring rest offset.void
setSpringStiffness(double stiffness)
Sets the spring stiffness.void
setUpperLimit(double upperLimit)
Sets the upper limit in meters.void
setUpperLimitEnabled(boolean flag)
Sets whether the upper limit is enabled.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()
protected void
updateSpringCoefficients()
Computes the spring coefficients from the current state of the joint.-
Methods inherited from class AbstractPairedBodyJoint
getBody, getBody1, getBody2, getBodyCount, getOtherBody, getReducedInertia, getReducedMass, isEnabled, isMember, setCollisionAllowed
-
Methods inherited from class AbstractJoint
getBodies, getBodyIterator, getConstraintImpulseMixing, getErrorReductionParameter, getFrequency, getNaturalFrequency, getNaturalFrequency, getOwner, getSpringDampingCoefficient, getSpringStiffness, getUserData, isCollisionAllowed, setOwner, setUserData
-
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, getBody, getBodyCount, getBodyIterator, isCollisionAllowed, isEnabled, isMember, setCollisionAllowed
-
Methods inherited from interface PairedBodyJoint
getBody1, getBody2, getOtherBody
-
-
-
-
Field Detail
-
localAnchor1
protected final Vector2 localAnchor1
The local anchor point on the firstPhysicsBody
-
localAnchor2
protected final Vector2 localAnchor2
The local anchor point on the secondPhysicsBody
-
xAxis
protected final Vector2 xAxis
The axis representing the allowed line of motion
-
yAxis
protected final Vector2 yAxis
The perpendicular axis of the line of motion
-
referenceAngle
protected double referenceAngle
The initial angle between the twoPhysicsBody
s
-
upperLimitEnabled
protected boolean upperLimitEnabled
True if the upper limit is enabled
-
lowerLimitEnabled
protected boolean lowerLimitEnabled
True if the lower limit is enabled
-
upperLimit
protected double upperLimit
the upper limit in meters
-
lowerLimit
protected double lowerLimit
the lower limit in meters
-
motorEnabled
protected boolean motorEnabled
Whether the motor is enabled or not
-
motorSpeed
protected double motorSpeed
The target velocity in meters / second
-
maximumMotorForceEnabled
protected boolean maximumMotorForceEnabled
True if the motor force should be limited
-
maximumMotorForce
protected double maximumMotorForce
The maximum force the motor can apply in newtons
-
springEnabled
protected boolean springEnabled
True if the spring is enabled
-
springDamperEnabled
protected boolean springDamperEnabled
True if the spring-damper is enabled
-
springMode
protected int springMode
The spring mode (frequency or stiffness)
-
springFrequency
protected double springFrequency
The oscillation frequency in hz
-
springStiffness
protected double springStiffness
The stiffness of the spring
-
springDampingRatio
protected double springDampingRatio
The damping ratio
-
springMaximumForceEnabled
protected boolean springMaximumForceEnabled
True if the spring maximum force is enabled
-
springMaximumForce
protected double springMaximumForce
The maximum force the spring will apply
-
springRestOffset
protected double springRestOffset
The rest offset of the spring
-
-
Constructor Detail
-
PrismaticJoint
public PrismaticJoint(T body1, T body2, Vector2 anchor, Vector2 axis)
Minimal constructor.- Parameters:
body1
- the firstPhysicsBody
body2
- the secondPhysicsBody
anchor
- the anchor point in world coordinatesaxis
- the axis of allowed motion- Throws:
NullPointerException
- if body1, body2, anchor or axis is nullIllegalArgumentException
- if body1 == body2 or axis is the zero vector
-
-
Method Detail
-
toString
public String toString()
- Overrides:
toString
in classAbstractJoint<T extends PhysicsBody>
-
initializeConstraints
public void initializeConstraints(TimeStep step, Settings settings)
Description copied from interface:Joint
Performs any initialization of the velocity and position constraints.- Specified by:
initializeConstraints
in interfaceJoint<T extends PhysicsBody>
- Parameters:
step
- the time step informationsettings
- the current world settings
-
solveVelocityConstraints
public void solveVelocityConstraints(TimeStep step, Settings settings)
Description copied from interface:Joint
Solves the velocity constraints.- Specified by:
solveVelocityConstraints
in interfaceJoint<T extends PhysicsBody>
- Parameters:
step
- the time step informationsettings
- the current world settings
-
solvePositionConstraints
public boolean solvePositionConstraints(TimeStep step, Settings settings)
Description copied from interface:Joint
Solves the position constraints.- Specified by:
solvePositionConstraints
in interfaceJoint<T extends PhysicsBody>
- Parameters:
step
- the time step informationsettings
- the current world settings- Returns:
- boolean true if the position constraints were solved
-
updateSpringCoefficients
protected void updateSpringCoefficients()
Computes the spring coefficients from the current state of the joint.This method is intended to set the springStiffness OR springFrequency and damping for use during constraint solving.
-
getAnchor1
public Vector2 getAnchor1()
The original anchor point on body1 in world space.- Returns:
Vector2
-
getAnchor2
public Vector2 getAnchor2()
The original anchor point on body2 in world space.- Returns:
Vector2
-
getReactionForce
public Vector2 getReactionForce(double invdt)
Description copied from interface:Joint
Returns the force applied to thePhysicsBody
s in order to satisfy the constraint in newtons.- Specified by:
getReactionForce
in interfaceJoint<T extends PhysicsBody>
- Parameters:
invdt
- the inverse delta time- Returns:
Vector2
-
getReactionTorque
public double getReactionTorque(double invdt)
Description copied from interface:Joint
Returns the torque applied to thePhysicsBody
s in order to satisfy the constraint in newton-meters.- Specified by:
getReactionTorque
in interfaceJoint<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.
-
getLinearSpeed
public double getLinearSpeed()
Returns the current joint speed.Renamed from getJointSpeed in 5.0.0
- Returns:
- double
- Since:
- 5.0.0
-
getLinearTranslation
public double getLinearTranslation()
Returns the current joint translation.Renamed from getJointTranslation in 5.0.0
- Returns:
- double
- Since:
- 5.0.0
-
isMotorEnabled
public boolean isMotorEnabled()
Description copied from interface:LinearMotorJoint
Returns true if the motor is enabled.- Specified by:
isMotorEnabled
in interfaceLinearMotorJoint
- Returns:
- boolean
-
setMotorEnabled
public void setMotorEnabled(boolean motorEnabled)
Description copied from interface:LinearMotorJoint
Enables or disables the motor.- Specified by:
setMotorEnabled
in interfaceLinearMotorJoint
- Parameters:
motorEnabled
- true if the motor should be enabled
-
getMotorSpeed
public double getMotorSpeed()
Description copied from interface:LinearMotorJoint
Returns the target motor speed in meters / second.- Specified by:
getMotorSpeed
in interfaceLinearMotorJoint
- Returns:
- double
-
setMotorSpeed
public void setMotorSpeed(double motorSpeed)
Description copied from interface:LinearMotorJoint
Sets the target motor speed.- Specified by:
setMotorSpeed
in interfaceLinearMotorJoint
- Parameters:
motorSpeed
- the target motor speed in meters / second- See Also:
LinearMotorJoint.setMaximumMotorForce(double)
-
getMaximumMotorForce
public double getMaximumMotorForce()
Description copied from interface:LinearMotorJoint
Returns the maximum force the motor can apply to the joint to achieve the target speed.- Specified by:
getMaximumMotorForce
in interfaceLinearMotorJoint
- Returns:
- double
-
setMaximumMotorForce
public void setMaximumMotorForce(double maximumMotorForce)
Description copied from interface:LinearMotorJoint
Sets the maximum force the motor can apply to the joint to achieve the target speed.- Specified by:
setMaximumMotorForce
in interfaceLinearMotorJoint
- Parameters:
maximumMotorForce
- the maximum force in newtons; must be greater than zero- See Also:
LinearMotorJoint.setMotorSpeed(double)
-
setMaximumMotorForceEnabled
public void setMaximumMotorForceEnabled(boolean enabled)
Description copied from interface:LinearMotorJoint
Sets whether the maximum motor force is enabled.- Specified by:
setMaximumMotorForceEnabled
in interfaceLinearMotorJoint
- Parameters:
enabled
- true if the maximum motor force should be enabled
-
isMaximumMotorForceEnabled
public boolean isMaximumMotorForceEnabled()
Description copied from interface:LinearMotorJoint
Returns true if the maximum motor force is enabled.- Specified by:
isMaximumMotorForceEnabled
in interfaceLinearMotorJoint
- Returns:
- boolean
-
getMotorForce
public double getMotorForce(double invdt)
Description copied from interface:LinearMotorJoint
Returns the applied motor force.- Specified by:
getMotorForce
in interfaceLinearMotorJoint
- Parameters:
invdt
- the inverse delta time- Returns:
- double
-
getSpringDampingRatio
public double getSpringDampingRatio()
Description copied from interface:LinearSpringJoint
Returns the damping ratio for the spring's damper.- Specified by:
getSpringDampingRatio
in interfaceLinearSpringJoint
- Returns:
- double
-
setSpringDampingRatio
public void setSpringDampingRatio(double dampingRatio)
Description copied from interface:LinearSpringJoint
Sets the damping ratio.Larger values reduce the oscillation of the spring.
- Specified by:
setSpringDampingRatio
in interfaceLinearSpringJoint
- Parameters:
dampingRatio
- the damping ratio; in the range (0, 1]
-
getSpringFrequency
public double getSpringFrequency()
Description copied from interface:LinearSpringJoint
Returns the spring frequency.- Specified by:
getSpringFrequency
in interfaceLinearSpringJoint
- Returns:
- double
-
getSpringStiffness
public double getSpringStiffness()
Description copied from interface:LinearSpringJoint
Returns the spring stiffness.- Specified by:
getSpringStiffness
in interfaceLinearSpringJoint
- Returns:
- double
-
setSpringFrequency
public void setSpringFrequency(double frequency)
Description copied from interface:LinearSpringJoint
Sets the spring frequency.Larger values increase the stiffness of the spring.
Calling this method puts the spring into fixed frequency mode. In this mode, the spring stiffness is computed based on the frequency.
- Specified by:
setSpringFrequency
in interfaceLinearSpringJoint
- Parameters:
frequency
- the spring frequency in hz; must be greater than zero
-
setSpringStiffness
public void setSpringStiffness(double stiffness)
Description copied from interface:LinearSpringJoint
Sets the spring stiffness.Larger values increase the stiffness of the spring.
Calling this method puts the spring into fixed stiffness mode. In this mode, the spring frequency is computed based on the stiffness.
- Specified by:
setSpringStiffness
in interfaceLinearSpringJoint
- Parameters:
stiffness
- the spring stiffness (k); must be greater than zero
-
getMaximumSpringForce
public double getMaximumSpringForce()
Description copied from interface:LinearSpringJoint
Returns the maximum spring force that will be applied.- Specified by:
getMaximumSpringForce
in interfaceLinearSpringJoint
- Returns:
- double
-
setMaximumSpringForce
public void setMaximumSpringForce(double maximum)
Description copied from interface:LinearSpringJoint
Sets the maximum force the spring can apply.- Specified by:
setMaximumSpringForce
in interfaceLinearSpringJoint
- Parameters:
maximum
- the maximum force
-
isMaximumSpringForceEnabled
public boolean isMaximumSpringForceEnabled()
Description copied from interface:LinearSpringJoint
Returns true if the spring force is limited to the maximum.- Specified by:
isMaximumSpringForceEnabled
in interfaceLinearSpringJoint
- Returns:
- boolean
-
setMaximumSpringForceEnabled
public void setMaximumSpringForceEnabled(boolean enabled)
Description copied from interface:LinearSpringJoint
Sets whether the spring force is limited to the maximum.- Specified by:
setMaximumSpringForceEnabled
in interfaceLinearSpringJoint
- Parameters:
enabled
- true if the spring force should be limited
-
isSpringEnabled
public boolean isSpringEnabled()
Description copied from interface:LinearSpringJoint
Returns true if the spring is enabled.- Specified by:
isSpringEnabled
in interfaceLinearSpringJoint
- Returns:
- boolean
-
setSpringEnabled
public void setSpringEnabled(boolean enabled)
Description copied from interface:LinearSpringJoint
Sets whether the spring is enabled or not.- Specified by:
setSpringEnabled
in interfaceLinearSpringJoint
- Parameters:
enabled
- true if the spring should be enabled
-
isSpringDamperEnabled
public boolean isSpringDamperEnabled()
Description copied from interface:LinearSpringJoint
Returns true if the damper is enabled for the spring.NOTE: for the damper to have any effect, the spring must be enabled.
- Specified by:
isSpringDamperEnabled
in interfaceLinearSpringJoint
- Returns:
- boolean
- See Also:
LinearSpringJoint.isSpringEnabled()
-
setSpringDamperEnabled
public void setSpringDamperEnabled(boolean enabled)
Description copied from interface:LinearSpringJoint
Sets whether the spring's damper is enabled or not.NOTE: for the damper to have any effect, the spring must be enabled.
- Specified by:
setSpringDamperEnabled
in interfaceLinearSpringJoint
- Parameters:
enabled
- true if the damper should be enabled- See Also:
LinearSpringJoint.setSpringEnabled(boolean)
-
getSpringForce
public double getSpringForce(double invdt)
Description copied from interface:LinearSpringJoint
Returns the force in netwons applied by the spring in the last timestep.- Specified by:
getSpringForce
in interfaceLinearSpringJoint
- Parameters:
invdt
- the inverse delta time- Returns:
- double
-
getSpringMode
public int getSpringMode()
Description copied from interface:LinearSpringJoint
Returns the current spring mode.NOTE: The spring mode is set automatically when you call either
LinearSpringJoint.setSpringFrequency(double)
orLinearSpringJoint.setSpringStiffness(double)
. Use this method to store the spring mode when saving the simulation state and use the value to call eitherLinearSpringJoint.setSpringFrequency(double)
orLinearSpringJoint.setSpringStiffness(double)
.- Specified by:
getSpringMode
in interfaceLinearSpringJoint
- Returns:
- int
- See Also:
Joint.SPRING_MODE_FREQUENCY
,Joint.SPRING_MODE_STIFFNESS
-
setSpringRestOffset
public void setSpringRestOffset(double offset)
Set's the spring rest offset.This can be any value and is used to offset the spring's rest distance. This is only applicable when the spring is enabled.
- Parameters:
offset
- the offset- Since:
- 5.0.0
-
getSpringRestOffset
public double getSpringRestOffset()
Returns the spring's rest offset.- Returns:
- double
- Since:
- 5.0.0
-
getUpperLimit
public double getUpperLimit()
Description copied from interface:LinearLimitsJoint
Returns the upper limit in meters.- Specified by:
getUpperLimit
in interfaceLinearLimitsJoint
- Returns:
- double
-
setUpperLimit
public void setUpperLimit(double upperLimit)
Description copied from interface:LinearLimitsJoint
Sets the upper limit in meters.- Specified by:
setUpperLimit
in interfaceLinearLimitsJoint
- Parameters:
upperLimit
- the upper limit in meters
-
setUpperLimitEnabled
public void setUpperLimitEnabled(boolean flag)
Description copied from interface:LinearLimitsJoint
Sets whether the upper limit is enabled.- Specified by:
setUpperLimitEnabled
in interfaceLinearLimitsJoint
- Parameters:
flag
- true if the upper limit should be enabled
-
isUpperLimitEnabled
public boolean isUpperLimitEnabled()
Description copied from interface:LinearLimitsJoint
Returns true if the upper limit is enabled.- Specified by:
isUpperLimitEnabled
in interfaceLinearLimitsJoint
- Returns:
- boolean true if the upper limit is enabled
-
getLowerLimit
public double getLowerLimit()
Description copied from interface:LinearLimitsJoint
Returns the lower limit in meters.- Specified by:
getLowerLimit
in interfaceLinearLimitsJoint
- Returns:
- double
-
setLowerLimit
public void setLowerLimit(double lowerLimit)
Description copied from interface:LinearLimitsJoint
Sets the lower limit in meters.- Specified by:
setLowerLimit
in interfaceLinearLimitsJoint
- Parameters:
lowerLimit
- the lower limit in meters
-
setLowerLimitEnabled
public void setLowerLimitEnabled(boolean flag)
Description copied from interface:LinearLimitsJoint
Sets whether the lower limit is enabled.- Specified by:
setLowerLimitEnabled
in interfaceLinearLimitsJoint
- Parameters:
flag
- true if the lower limit should be enabled
-
isLowerLimitEnabled
public boolean isLowerLimitEnabled()
Description copied from interface:LinearLimitsJoint
Returns true if the lower limit is enabled.- Specified by:
isLowerLimitEnabled
in interfaceLinearLimitsJoint
- Returns:
- boolean true if the lower limit is enabled
-
setLimits
public void setLimits(double lowerLimit, double upperLimit)
Description copied from interface:LinearLimitsJoint
Sets both the lower and upper limits.- Specified by:
setLimits
in interfaceLinearLimitsJoint
- Parameters:
lowerLimit
- the lower limit in metersupperLimit
- the upper limit in meters
-
setLimitsEnabled
public void setLimitsEnabled(double lowerLimit, double upperLimit)
Description copied from interface:LinearLimitsJoint
Sets both the lower and upper limits and enables both.- Specified by:
setLimitsEnabled
in interfaceLinearLimitsJoint
- Parameters:
lowerLimit
- the lower limit in metersupperLimit
- the upper limit in meters
-
setLimitsEnabled
public void setLimitsEnabled(boolean flag)
Description copied from interface:LinearLimitsJoint
Enables or disables both the lower and upper limits.- Specified by:
setLimitsEnabled
in interfaceLinearLimitsJoint
- Parameters:
flag
- true if both limits should be enabled
-
setLimits
public void setLimits(double limit)
Description copied from interface:LinearLimitsJoint
Sets both the lower and upper limits to the given limit.- Specified by:
setLimits
in interfaceLinearLimitsJoint
- Parameters:
limit
- the desired limit in meters
-
setLimitsEnabled
public void setLimitsEnabled(double limit)
Description copied from interface:LinearLimitsJoint
Sets both the lower and upper limits to the given limit and enables both.- Specified by:
setLimitsEnabled
in interfaceLinearLimitsJoint
- Parameters:
limit
- the desired limit in meters
-
getAxis
public Vector2 getAxis()
Returns the axis in which the joint is allowed move along in world coordinates.- Returns:
Vector2
- Since:
- 3.0.0
-
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.
This can also be used to override the initial angle between the bodies.
- Parameters:
angle
- the reference angle- Since:
- 3.0.1
- See Also:
getReferenceAngle()
-
-