HGE2D-0.1.6.2: 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] -> b Source #

Find the closest in [b] to a

furthest :: (Positioned a, Positioned b) => a -> [b] -> 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

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

Merges two bounding boxes, creating a new one which wraps around the inputs

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