netwire-4.0.5: Flexible wire arrows for FRP

Maintainer Ertugrul Soeylemez None

Control.Wire.Prefab.Move

Description

This module provides the wires for various kinds of moving objects. In particular this includes various calculus wires like integrals and differentials.

Synopsis

# Calculus

## Integrals

integral :: VectorSpace b => b -> Wire e m (b, Scalar b) bSource

Integral wire. Produces position from velocity in the sense of the given vector space.

• Depends: previous instant.

integral_ :: (VectorSpace b, Scalar b ~ Time) => b -> Wire e m b bSource

Same as `integral`, but with respect to time.

• Depends: previous instant.

Arguments

 :: VectorSpace b => (w -> b -> b -> b) Post-update function. -> b Initial value. -> Wire e m ((b, w), Scalar b) b

Variant of `integral`, where you can specify a post-update function, which receives the previous position as well as the current (in that order). This is useful for limiting the output (think of robot arms that can't be moved freely).

• Depends: current instant if the post-update function is strict in its first argument, previous instant if not.

integralLim_ :: (VectorSpace b, Scalar b ~ Time) => (w -> b -> b -> b) -> b -> Wire e m (b, w) bSource

Same as `integralLim`, but with respect to time.

• Depends: previous instant.

integral1 :: VectorSpace b => b -> Wire e m (b, Scalar b) bSource

Non-delaying variant of `integral`.

• Depends: current instant.

integral1_ :: (Monad m, VectorSpace b, Scalar b ~ Time) => b -> Wire e m b bSource

Non-delaying variant of `integral_`.

• Depends: current instant.

Arguments

 :: VectorSpace b => (w -> b -> b -> b) Post-update function. -> b Initial value. -> Wire e m ((b, w), Scalar b) b

Non-delaying variant of `integralLim`.

• Depends: current instant.

integralLim1_ :: (VectorSpace b, Scalar b ~ Time) => (w -> b -> b -> b) -> b -> Wire e m (b, w) bSource

Non-delaying variant of `integralLim_`.

• Depends: current instant.

## Differentials

Arguments

 :: (Eq dt, Fractional dt, VectorSpace b, Scalar b ~ dt) => (b -> dt -> b) Handle exceptional change rates (receives dx and dt). -> b Initial position. -> Wire e m (b, dt) b

Derivative. Receives `x` and `dt` and calculates the change rate `dx/dt`. Note that `dt` despite its name does not have to be time.

The exception handler function is called when `dt` is zero. That function's result is the wire's output for those instants. If you don't want to handle exceptional cases specially, just pass `(^/)` as the handler function.

• Depends: current instant.

Arguments

 :: (Monad m, VectorSpace b, Scalar b ~ Time) => (b -> Time -> b) Handle exceptional cases. -> b Initial position. -> Wire e m b b

Same as `derivative`, but with respect to time.

• Depends: current instant.

# Simulations/games

Arguments

 :: forall b m dt e w . (VectorSpace b, Scalar b ~ dt) => (w -> ObjectState b -> ObjectState b) Post-move update function. -> ObjectState b Initial state. -> Wire e m (ObjectDiff b, w, dt) (ObjectState b)

Objects are generalized integrals. They are controlled through velocity and/or acceleration and can be collision-checked as well as instantly teleported.

The post-move update function receives the world state and the current object state. It is applied just before the wire produces its output. You can use it to perform collision-checks or to limit the velocity.

Note that teleportation doesn't change the velocity.

• Depends: current instant.

Arguments

 :: (Monad m, VectorSpace b, Scalar b ~ Time) => (w -> ObjectState b -> ObjectState b) Post-move update function. -> ObjectState b Initial state. -> Wire e m (ObjectDiff b, w) (ObjectState b)

Same as `object`, but with respect to time.

• Depends: current instant.

data ObjectState a Source

Object state. This includes the position and velocity.

Constructors

 ObjectState FieldsobjPosition :: aPosition. objVelocity :: aVelocity.

Instances

 Typeable1 ObjectState Eq a => Eq (ObjectState a) (Typeable (ObjectState a), Data a) => Data (ObjectState a) (Eq (ObjectState a), Ord a) => Ord (ObjectState a) Read a => Read (ObjectState a) Show a => Show (ObjectState a)

data ObjectDiff a Source

Differential for objects.

Constructors

 Accelerate a Accelerate (units per second). Position a Teleport to the given position instantly (velocity will be unchanged). Velocity a Specify velocity (units per second).

Instances

 Typeable1 ObjectDiff Eq a => Eq (ObjectDiff a) (Typeable (ObjectDiff a), Data a) => Data (ObjectDiff a) (Eq (ObjectDiff a), Ord a) => Ord (ObjectDiff a) Read a => Read (ObjectDiff a) Show a => Show (ObjectDiff a)