Maintainer | Ertugrul Soeylemez <es@ertes.de> |
---|---|
Safe Haskell | None |
This module provides the wires for various kinds of moving objects. In particular this includes various calculus wires like integrals and differentials.
- integral :: VectorSpace b => b -> Wire e m (b, Scalar b) b
- integral_ :: (VectorSpace b, Scalar b ~ Time) => b -> Wire e m b b
- integralLim :: VectorSpace b => (w -> b -> b -> b) -> b -> Wire e m ((b, w), Scalar b) b
- integralLim_ :: (VectorSpace b, Scalar b ~ Time) => (w -> b -> b -> b) -> b -> Wire e m (b, w) b
- integral1 :: VectorSpace b => b -> Wire e m (b, Scalar b) b
- integral1_ :: (Monad m, VectorSpace b, Scalar b ~ Time) => b -> Wire e m b b
- integralLim1 :: VectorSpace b => (w -> b -> b -> b) -> b -> Wire e m ((b, w), Scalar b) b
- integralLim1_ :: (VectorSpace b, Scalar b ~ Time) => (w -> b -> b -> b) -> b -> Wire e m (b, w) b
- derivative :: (Eq dt, Fractional dt, VectorSpace b, Scalar b ~ dt) => (b -> dt -> b) -> b -> Wire e m (b, dt) b
- derivative_ :: (Monad m, VectorSpace b, Scalar b ~ Time) => (b -> Time -> b) -> b -> Wire e m b b
- object :: forall b m dt e w. (VectorSpace b, Scalar b ~ dt) => (w -> ObjectState b -> ObjectState b) -> ObjectState b -> Wire e m (ObjectDiff b, w, dt) (ObjectState b)
- object_ :: (Monad m, VectorSpace b, Scalar b ~ Time) => (w -> ObjectState b -> ObjectState b) -> ObjectState b -> Wire e m (ObjectDiff b, w) (ObjectState b)
- data ObjectState a = ObjectState {
- objPosition :: a
- objVelocity :: a
- data ObjectDiff a
- = Accelerate a
- | Position a
- | Velocity a
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.
:: 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.
:: 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
:: (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.
:: (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
:: 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.
:: (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.
ObjectState | |
|
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.
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). |
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) |