Copyright | (c) 2016 Martin Buck |
---|---|

License | see LICENSE |

Safe Haskell | None |

Language | Haskell2010 |

Containing geometrical functions

- rad2deg :: Double -> Double
- deg2rad :: Double -> Double
- radRealPos :: RealPosition -> RealPosition -> Radian
- velAngle :: Velocity -> Radian
- distance :: (Positioned a, Positioned b) => a -> b -> Double
- distanceSqr :: (Positioned a, Positioned b) => a -> b -> Double
- distanceBB :: (Positioned a, HasBoundingBox b) => a -> b -> Double
- distanceBBSqr :: (Positioned a, HasBoundingBox b) => a -> b -> Double
- direction :: (Positioned a, Positioned b) => a -> b -> RealPosition
- closest :: (Positioned a, Positioned b) => a -> [b] -> Maybe b
- furthest :: (Positioned a, Positioned b) => a -> [b] -> Maybe b
- interceptionPos :: (RealPosition, Double) -> (RealPosition, Velocity) -> RealPosition
- makeRB :: RealPosition -> Velocity -> Pixel -> Pixel -> RigidBody
- sizedBB :: RealPosition -> Pixel -> Pixel -> BoundingBox
- sizeBB :: BoundingBox -> (Pixel, Pixel)
- centerBB :: BoundingBox -> RealPosition
- bbFromList :: Positioned a => [a] -> BoundingBox
- mergeBB :: BoundingBox -> BoundingBox -> BoundingBox
- makeBB :: RealPosition -> Pixel -> Pixel -> BoundingBox
- applyVelocity :: RealPosition -> Velocity -> Millisecond -> RealPosition

# Documentation

radRealPos :: RealPosition -> RealPosition -> Radian Source #

Calculate angle in radians between two positions in space, from the first to the secind

distance :: (Positioned a, Positioned b) => a -> b -> Double Source #

Distance between two positions

distanceSqr :: (Positioned a, Positioned b) => a -> b -> Double Source #

Squared distance between two positions Faster than calculating the distance. Can be used to e.g. compare distances cheaply

distanceBB :: (Positioned a, HasBoundingBox b) => a -> b -> Double Source #

Distance between a position and a bounding box

distanceBBSqr :: (Positioned a, HasBoundingBox b) => a -> b -> Double Source #

Squared distance between a position and a bounding box Faster than calculating the distance. Can be used to e.g. compare distances cheaply

direction :: (Positioned a, Positioned b) => a -> b -> RealPosition Source #

Calculate the direction vector between two positions

closest :: (Positioned a, Positioned b) => a -> [b] -> Maybe b Source #

Find the closest in [b] to a

furthest :: (Positioned a, Positioned b) => a -> [b] -> Maybe b Source #

Find the furthest in [b] to a

interceptionPos :: (RealPosition, Double) -> (RealPosition, Velocity) -> RealPosition Source #

Given a position and projectile speed of a gun / turret and an object defined by its current position and velocity Calculates the position where both will intercept. (useful for pre-aiming)

sizedBB :: RealPosition -> Pixel -> Pixel -> BoundingBox Source #

Builder to get a BoundingBox from its center position and sizes

centerBB :: BoundingBox -> RealPosition Source #

Calculates the center of a BoundingBox

bbFromList :: Positioned a => [a] -> BoundingBox Source #

Calculates the bounding box of multiple positions

mergeBB :: BoundingBox -> BoundingBox -> BoundingBox Source #

Merges two bounding boxes, creating a new one which wraps around the inputs In case a nullBB is passed as one parameter, the other BoundingBox is returned

makeBB :: RealPosition -> Pixel -> Pixel -> BoundingBox Source #

Builds a BoundingBox

applyVelocity :: RealPosition -> Velocity -> Millisecond -> RealPosition Source #

Given a position, time and veilocty it calculates the position where the moving object would be