mdgriffith / ui-animation

All Work from this Repo has been published at https://github.com/mdgriffith/elm-style-animation
BSD 3-Clause "New" or "Revised" License
5 stars 0 forks source link

Angles are provided as absolute values that wrap at 360 degrees #8

Open mdgriffith opened 8 years ago

mdgriffith commented 8 years ago

This is to allow something like this to work as expected.

Animation.loop [Animation.rotate (turn 1)]

Comparing this strategy to Absolute and Relative angles

Relative angles:

[ rotate (turn 2)
, rotate (turn 0.25)
, rotate (turn 2.5)
]

would result in 4.75 turns forward.

We can describe this approach as you specify how far you want to go and in what direction. But you don't get to specify exactly where you want to end up without knowing every previous rotation.

Absolute angles:

[ rotate (turn 2)
, rotate (turn 0.25)
, rotate (turn 2.5)
]

Would result in

I believe the "reverse for 1.75 turns" is the counter intuitive step. If that rotation command rotate (turn 0.25) is given at some other point in the code other than right next to rotate (turn 2), and it turns in reverse for 1.75 turns...I think that would most likely be unexpected.

We can describe this approach as you specify where you want to end up. But you don't get to specify how long it takes to get there.

Our compromise (absolutely specified angles that wrap at full rotations)

[ rotate (turn 2)
, rotate (turn 0.25)
, rotate (turn 2.5)
]

Wrapping at every whole number this results in the following:

Resulting in 4.5 turns

We are also able to achieve the same result as absolute units by doing the following:

[ rotate (turn 2)
, rotate (turn -1.75)
, rotate (turn 2.5)
]

Which results in

Advantages