HGE2D-0.1.7.4: 2D game engine written in Haskell

Copyright(c) 2016 Martin Buck
Licensesee LICENSE
Safe HaskellNone
LanguageHaskell2010

HGE2D.Geometry

Description

Containing geometrical functions

Synopsis

Documentation

rad2deg :: Double -> Double Source #

Transform an angle in radians to an angle in degrees

deg2rad :: Double -> Double Source #

Transform an angle in degrees to an angle in radians

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

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

velAngle :: Velocity -> Radian Source #

Calculate angle of a velocity

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

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)

makeRB :: RealPosition -> Velocity -> Pixel -> Pixel -> RigidBody Source #

Builder for a rigidbody

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

Builder to get a BoundingBox from its center position and sizes

sizeBB :: BoundingBox -> (Pixel, Pixel) Source #

Calculates the size of a BoundingBox

centerBB :: BoundingBox -> RealPosition Source #

Calculates the center of a BoundingBox

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

Calculates the bounding box of multiple positions

isNullBB :: BoundingBox -> Bool Source #

Testing whether a BoundingBox has the same min and max values

nullBB :: BoundingBox Source #

A BoundingBox which counts as null, having the same min and max position

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