w0rm/elm-physics/6.0.0

NOTE: the latest version is 6.2.0

Physics.Constraint

type alias Constraint =
Constraint

Limit the freedom of movement of two bodies relative to each other.

Pass a constrain function in the simulation config. For example, to drag a body with the mouse, connect a mouse to a point on the box with pointToPoint:

constrain id =
    if id == "mouse" then
        Just
            (\otherId ->
                if otherId == "box" then
                    [ pointToPoint Point3d.origin pointOnBox ]


                else
                    []
            )


    else
        Nothing

Constraints are skipped unless at least one body is dynamic.

Point3d Meters BodyCoordinates
-> Point3d Meters BodyCoordinates
-> Constraint

Connect a point on the first body with a point on the second body. This doesn’t limit the freedom of rotation of two bodies.

Axis3d Meters BodyCoordinates
-> Axis3d Meters BodyCoordinates
-> Constraint

Keep two bodies connected with each other and limit the freedom of rotation. Useful for e.g. connecting a window to a window frame, or to connect a wheel to a car.

distance : Length -> Constraint

Keep the centers of mass of two bodies at the constant distance from each other.

Frame3d Meters BodyCoordinates {}
-> Frame3d Meters BodyCoordinates {}
-> Constraint

Keep two bodies connected with each other and remove all degrees of freedom between bodies.