Hipmunk-5.0.0: A Haskell binding for Chipmunk.Source codeContentsIndex
Physics.Hipmunk.Constraint
Portabilityportable (needs FFI)
Stabilityprovisional
Maintainerfelipe.lessa@gmail.com
Contents
Common interface
Forgetting the phantom type
Constraint types
Pin joint
Slide joint
Pivot joint
Groove joint
Gear joint
Damped spring
Damped rotary spring
Rotary limit
Simple motor
Description
Constraints that restrict the bodies' movement.
Synopsis
newConstraint :: ConstraintType a => Body -> Body -> a -> IO (Constraint a)
redefineC :: ConstraintType a => Constraint a -> a -> IO ()
setBiasCoefC :: BiasCoef -> Constraint a -> IO ()
data Constraint a
data Unknown
forgetC :: Constraint a -> Constraint Unknown
data Pin = Pin {
pinAnchor1 :: !Position
pinAnchor2 :: !Position
}
data Slide = Slide {
slideAnchor1 :: !Position
slideAnchor2 :: !Position
slideMinDist :: !Distance
slideMaxDist :: !Distance
}
data Pivot
= Pivot1 {
pivotPos :: !Position
}
| Pivot2 {
pivotAnchor1 :: !Position
pivotAnchor2 :: !Position
}
data Groove = Groove {
groovePoints :: !(Position, Position)
groovePivot :: !Position
}
data Gear = Gear {
gearPhase :: !Angle
gearRatio :: !CpFloat
}
data DampedSpring = DampedSpring {
dampedAnchor1 :: !Position
dampedAnchor2 :: !Position
dampedRestLength :: !Distance
dampedStiffness :: !CpFloat
dampedDamping :: !Damping
}
data DampedRotarySpring = DampedRotarySpring {
dampedRotRestAngle :: !Angle
dampedRotStiffness :: !CpFloat
dampedRotDamping :: !Damping
}
data RotaryLimit = RotaryLimit {
rotaryMinDist :: Distance
rotaryMaxDist :: Distance
}
data SimpleMotor = SimpleMotor {
simpleMotorRate :: CpFloat
}
Common interface
newConstraint :: ConstraintType a => Body -> Body -> a -> IO (Constraint a)Source

newConstraint b1 b2 type_ connects the two bodies b1 and b2 with a constraint of the given type. Note that you should add the Constraint to a space.

The ConstraintType type class is implemented by all constraint types to allow them to be manipulated by the same framework while retaining type-safety, consequently it isn't exported.

redefineC :: ConstraintType a => Constraint a -> a -> IO ()Source
redefine constr type_ redefines constr's parameters on-the-fly, allowing you to dynamically change the constraint's behaviour.
setBiasCoefC :: BiasCoef -> Constraint a -> IO ()Source
Sets the constraint's bias coefficient. By default it is equal to the last value set globally with setConstraintBiasCoef, which initially is 0.1
data Constraint a Source
Represents a constraint between two bodies. Don't forget to add the bodies and the constraint itself to the space. The phantom type indicates the type of the constraint.
show/hide Instances
Forgetting the phantom type
These functions discard the phantom type of the constraint. They're useful, for example, if you want to put different constraints in a homogeneous data structure (such as a list).
data Unknown Source
An unknown constraint "type". Note that this isn't a ConstraintType because you can't create a constraint of Unknown type.
forgetC :: Constraint a -> Constraint UnknownSource
Completely safe function that discards the constraint type (which is a phantom type). You can "remember" it again by using unsafeRemember from the Unsafe module.
Constraint types
There are currently nine types of constraints. When appending a number to a property, we hint that it refer to one of the bodies that the constraint is intercting with (e.g. "Second anchor" is the position of the anchor on the second body in its coordinates).
Pin joint
data Pin Source
A pin joint connects the bodies with a solid pin. The anchor points are kept at a fixed distance.
Constructors
Pin
pinAnchor1 :: !PositionFirst anchor.
pinAnchor2 :: !PositionSecond anchor.
show/hide Instances
Eq Pin
Ord Pin
Show Pin
ConstraintType Pin
Slide joint
data Slide Source
A slide joint is similar to a pin joint, however it has a minimum and a maximum distance.
Constructors
Slide
slideAnchor1 :: !PositionFirst anchor.
slideAnchor2 :: !PositionSecond anchor.
slideMinDist :: !DistanceMinimum distance.
slideMaxDist :: !DistanceMaximum distance.
show/hide Instances
Pivot joint
data Pivot Source
A pivot joint allows the bodies to pivot around a single point.
Constructors
Pivot1You may specify the pivot point in world's coordinates (so both bodies should be already in place).
pivotPos :: !PositionPivot point in world's coordinates.
Pivot2Or you may specify the joint as two anchors (on each body's coordinates), removing the need having the bodies already in place.
pivotAnchor1 :: !PositionFirst anchor.
pivotAnchor2 :: !PositionSecond anchor.
show/hide Instances
Groove joint
data Groove Source
A groove joint attaches a point on the second body to a groove in the first one.
Constructors
Groove
groovePoints :: !(Position, Position)Groove, in first body's coordinates.
groovePivot :: !PositionPivot, in second body's coordinates.
show/hide Instances
Gear joint
data Gear Source
A gear joint restricts the bodies movement to be coordinated as if they were attached like dented gears.
Constructors
Gear
gearPhase :: !AnglePhase of the movement.
gearRatio :: !CpFloatRatio between the gears.
show/hide Instances
Eq Gear
Ord Gear
Show Gear
ConstraintType Gear
Damped spring
data DampedSpring Source
A simple damped spring. Generally this constraint should be used instead of applyDampedSpring.
Constructors
DampedSpring
dampedAnchor1 :: !PositionFirst anchor.
dampedAnchor2 :: !PositionSecond anchor.
dampedRestLength :: !DistanceRest length.
dampedStiffness :: !CpFloatStiffness.
dampedDamping :: !DampingDamping.
show/hide Instances
Damped rotary spring
data DampedRotarySpring Source
A damped rotary spring constraint.
Constructors
DampedRotarySpring
dampedRotRestAngle :: !AngleRest angle.
dampedRotStiffness :: !CpFloatStiffness.
dampedRotDamping :: !DampingDamping.
show/hide Instances
Rotary limit
data RotaryLimit Source
A rotary limit constraints the difference of angle between two bodies.
Constructors
RotaryLimit
rotaryMinDist :: DistanceMinimum distance.
rotaryMaxDist :: DistanceMaximum distance.
show/hide Instances
Simple motor
data SimpleMotor Source
A simple motor that applies opposite impulses to each body. The rate is used to compute the torque.
Constructors
SimpleMotor
simpleMotorRate :: CpFloatRate.
show/hide Instances
Produced by Haddock version 2.4.2