rsagl-math- The RogueStar Animation and Graphics Library: Mathematics



Provides generic typeclasses for common operations among many types: addition, subtraction, scalar multiplication, magnitude, and zero.



class AbstractAdd p v | p -> v whereSource

A data type that supports addition.


add :: p -> v -> pSource

class AbstractScale v whereSource

A data type that supports scalar multiplication.

  • scalarMultiply 0 a = zero


scalarMultiply :: RSdouble -> v -> vSource

abstractScaleTo :: (AbstractScale v, AbstractMagnitude v) => RSdouble -> v -> vSource

Force a vector to the specified magnitude.

abstractSum :: (AbstractAdd p v, AbstractZero p) => [v] -> pSource

Sum of a list.

abstractAverage :: (AbstractAdd p v, AbstractSubtract p v, AbstractVector v, AbstractZero p) => [p] -> pSource

Average of a list.

abstractDistance :: (AbstractMagnitude v, AbstractSubtract p v) => p -> p -> RSdoubleSource

Distance between two points, based on the magnitude of the difference.