Safe Haskell | None |
---|---|

Language | Haskell2010 |

- data Vec2 a = Vec2 {}
- pos2vec :: Coords Pos -> Vec2 Pos
- vec2pos :: Vec2 Pos -> Coords Pos
- speed2vec :: Coords Vel -> Vec2 Vel
- vec2speed :: Vec2 Vel -> Coords Vel
- translatedFullCircle :: Vec2 Pos -> Float -> Float -> Int -> [Vec2 Pos]
- translatedFullCircleFromQuarterArc :: Vec2 Pos -> Float -> Float -> Int -> [Vec2 Pos]
- parabola :: Vec2 Pos -> Vec2 Vel -> Frame -> Vec2 Pos
- polyExtremities :: Vec2 Pos -> Float -> Float -> Int -> [Vec2 Pos]
- sumVec2d :: Vec2 a -> Vec2 a -> Vec2 a
- scalarProd :: Float -> Vec2 a -> Vec2 a
- rotateByQuarters :: Vec2 Pos -> [Vec2 Pos]
- data Pos
- data Vel
- data Acc

# Continuous coordinates

# Conversion to / from discrete coordinates

Discrete positions are converted to continuous positions by
placing them at the "pixel center", ie by applying an offset of (0.5, 0.5) in
`pos2vec`

.

Then, during the inverse transformation - in `vec2pos`

, coordinates are just
floored.

Discrete speeds are converted with `speed2vec`

. The half-pixel convention is not
applied for speeds. The inverse conversion is `vec2speed`

.

# Sampled continuous geometry

## Circle

:: Vec2 Pos | Center |

-> Float | Radius |

-> Float | The angle corresponding to the first sampled point |

-> Int | The total number of sampled points |

-> [Vec2 Pos] |

Samples a circle.

## Parabola

parabola :: Vec2 Pos -> Vec2 Vel -> Frame -> Vec2 Pos Source #

Using equation [2] in "Constant linear acceleration in any direction":

\[ \vec r = \vec r_0 + \vec v_0*t + {1 \over 2}* \vec a*t^2 \]

\[ where \]

\[ \vec r = current\;position \]

\[ \vec r_0 = initial\;position \]

\[ \vec v_0 = initial\;velocity \]

\[ \vec a = gravity\;force \]

\[ t = time \]

# Polygon extremities

:: Vec2 Pos | Center |

-> Float | Radius |

-> Float | Rotation angle |

-> Int | Number of sides of the polygon. |

-> [Vec2 Pos] |

Returns the extremities of a polygon. Note that it is equal to `translatedFullCircle`

# Vec2 utilities

rotateByQuarters :: Vec2 Pos -> [Vec2 Pos] Source #

Creates a list of 4 `Vec2`

from a single one by rotating it successively by pi/2.

# Reexports

Phantom type : position

DiscreteDistance (Coords Pos) Source # | Using bresenham 2d line algorithm. |

DiscreteInterpolation (Coords Pos) Source # | Using bresenham 2d line algorithm. |