Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Bindings to raymath
These were rewritten in Haskell instead of binding to C. All the functions are pure. This may not be an exact one-to-one mapping to the C code; some of the functions and high-level structures have been changed to be more idiomatic Haskell.
Synopsis
- epsilon :: Float
- deg2Rad :: Float
- rad2Deg :: Float
- clamp :: Float -> Float -> Float -> Float
- lerp :: Float -> Float -> Float -> Float
- normalize :: Float -> Float -> Float -> Float
- remap :: Float -> Float -> Float -> Float -> Float -> Float
- wrap :: Float -> Float -> Float -> Float
- floatEquals :: Float -> Float -> Bool
- class Vector a where
- asList :: a -> [Float]
- fromList :: [Float] -> a
- foldlV :: (b -> Float -> b) -> b -> a -> b
- foldrV :: (Float -> b -> b) -> b -> a -> b
- mapV :: (Float -> Float) -> a -> a
- zipWithV :: (Float -> Float -> Float) -> a -> a -> a
- zipWithV3 :: (Float -> Float -> Float -> Float) -> a -> a -> a -> a
- (|+|) :: a -> a -> a
- (|-|) :: a -> a -> a
- (|+) :: a -> Float -> a
- (|-) :: a -> Float -> a
- (|*|) :: a -> a -> a
- (|/|) :: a -> a -> a
- (|*) :: a -> Float -> a
- (|/) :: a -> Float -> a
- (|.|) :: a -> a -> Float
- zero :: a
- one :: a
- constant :: Float -> a
- vectorSum :: Foldable t => t a -> a
- additiveInverse :: a -> a
- multiplicativeInverse :: a -> a
- magnitudeSqr :: a -> Float
- magnitude :: a -> Float
- vectorDistanceSqr :: a -> a -> Float
- vectorDistance :: a -> a -> Float
- vectorNormalize :: a -> a
- vectorLerp :: a -> a -> Float -> a
- vectorMoveTowards :: a -> a -> Float -> a
- vectorClamp :: a -> a -> a -> a
- vectorClampValue :: a -> Float -> Float -> a
- vectorMin :: a -> a -> a
- vectorMax :: a -> a -> a
- vector2Angle :: Vector2 -> Vector2 -> Float
- vector2LineAngle :: Vector2 -> Vector2 -> Float
- vector2Transform :: Vector2 -> Matrix -> Vector2
- vector2Reflect :: Vector2 -> Vector2 -> Vector2
- vector2Rotate :: Vector2 -> Float -> Vector2
- vector2Refract :: Vector2 -> Vector2 -> Float -> Vector2
- vector3CrossProduct :: Vector3 -> Vector3 -> Vector3
- vector3Perpendicular :: Vector3 -> Vector3
- vector3Angle :: Vector3 -> Vector3 -> Float
- vector3OrthoNormalize :: Vector3 -> Vector3 -> (Vector3, Vector3)
- vector3Transform :: Vector3 -> Matrix -> Vector3
- vector3RotateByQuaternion :: Vector3 -> Quaternion -> Vector3
- vector3RotateByAxisAngle :: Vector3 -> Vector3 -> Float -> Vector3
- vector3CubicHermite :: Vector3 -> Vector3 -> Vector3 -> Vector3 -> Float -> Vector3
- vector3Reflect :: Vector3 -> Vector3 -> Vector3
- vector3Barycenter :: Vector3 -> (Vector3, Vector3, Vector3) -> Vector3
- vector3Unproject :: Vector3 -> Matrix -> Matrix -> Vector3
- vector3Refract :: Vector3 -> Vector3 -> Float -> Vector3
- matrixToList :: Matrix -> [Float]
- matrixFromList :: [Float] -> Matrix
- matrixConstant :: Float -> Matrix
- matrixDeterminant :: Matrix -> Float
- matrixTrace :: Matrix -> Float
- matrixTranspose :: Matrix -> Matrix
- matrixInvert :: Matrix -> Matrix
- matrixIdentity :: Matrix
- matrixAdd :: Matrix -> Matrix -> Matrix
- (/+/) :: Matrix -> Matrix -> Matrix
- matrixSubtract :: Matrix -> Matrix -> Matrix
- (/-/) :: Matrix -> Matrix -> Matrix
- matrixMultiply :: Matrix -> Matrix -> Matrix
- (/*/) :: Matrix -> Matrix -> Matrix
- matrixTranslate :: Float -> Float -> Float -> Matrix
- matrixRotate :: Vector3 -> Float -> Matrix
- matrixRotateX :: Float -> Matrix
- matrixRotateY :: Float -> Matrix
- matrixRotateZ :: Float -> Matrix
- matrixRotateXYZ :: Vector3 -> Matrix
- matrixRotateZYX :: Vector3 -> Matrix
- matrixScale :: Vector3 -> Matrix
- matrixFrustum :: Float -> Float -> Float -> Float -> Float -> Float -> Matrix
- matrixPerspective :: Float -> Float -> Float -> Float -> Matrix
- matrixOrtho :: Float -> Float -> Float -> Float -> Float -> Float -> Matrix
- matrixLookAt :: Vector3 -> Vector3 -> Vector3 -> Matrix
- matrixDecompose :: Matrix -> (Vector3, Quaternion, Vector3)
- quaternionIdentity :: Quaternion
- quaternionInvert :: Quaternion -> Quaternion
- quaternionMultiply :: Quaternion -> Quaternion -> Quaternion
- quaternionNormalize :: Quaternion -> Quaternion
- quaternionLerp :: Quaternion -> Quaternion -> Float -> Quaternion
- quaternionNLerp :: Quaternion -> Quaternion -> Float -> Quaternion
- quaternionSLerp :: Quaternion -> Quaternion -> Float -> Quaternion
- quaternionCubicHermiteSpline :: Quaternion -> Quaternion -> Quaternion -> Quaternion -> Float -> Quaternion
- quaternionFromVector3ToVector3 :: Vector3 -> Vector3 -> Quaternion
- quaternionFromMatrix :: Matrix -> Quaternion
- quaternionToMatrix :: Quaternion -> Matrix
- quaternionFromAxisAngle :: Vector3 -> Float -> Quaternion
- quaternionToAxisAngle :: Quaternion -> (Vector3, Float)
- quaternionFromEuler :: Float -> Float -> Float -> Quaternion
- quaternionToEuler :: Quaternion -> Vector3
- quaternionTransform :: Quaternion -> Matrix -> Quaternion
Utility constants
Float math
Clamp float to range (WARNING: this does not use the same argument order as raymath)
Calculate linear interpolation between two floats
Normalize input value within input range
:: Float | Input range start |
-> Float | Input range end |
-> Float | Output range start |
-> Float | Output range end |
-> Float | Input value |
-> Float |
Remap input value within input range to output range
Wrap input value from min to max
Vector math
asList :: a -> [Float] Source #
List representation of a vector
fromList :: [Float] -> a Source #
Vector representation of a list
foldlV :: (b -> Float -> b) -> b -> a -> b Source #
Left fold over a vector
foldrV :: (Float -> b -> b) -> b -> a -> b Source #
Right fold over a vector
mapV :: (Float -> Float) -> a -> a Source #
Map over a vector
zipWithV :: (Float -> Float -> Float) -> a -> a -> a Source #
Equivalent of zipWith
over a vector
zipWithV3 :: (Float -> Float -> Float -> Float) -> a -> a -> a -> a Source #
Equivalent of zipWith3
over a vector
Vector-vector addition
Vector-vector subtraction
(|+) :: a -> Float -> a Source #
Vector-scalar addition
(|-) :: a -> Float -> a Source #
Vector-scalar subtraction
Vector-vector multiplication
Vector-vector division
(|*) :: a -> Float -> a Source #
Vector-scalar multiplication
(|/) :: a -> Float -> a Source #
Vector-scalar division
(|.|) :: a -> a -> Float Source #
Vector-vector dot product
Zero vector
One vector
constant :: Float -> a Source #
Scalar to vector (all elements are set to the scalar)
vectorSum :: Foldable t => t a -> a Source #
Sum of all vectors in a structure
additiveInverse :: a -> a Source #
Vector additive inverse
multiplicativeInverse :: a -> a Source #
Vector multiplicative inverse
magnitudeSqr :: a -> Float Source #
Squared magnitude of a vector
magnitude :: a -> Float Source #
Vector magnitude
vectorDistanceSqr :: a -> a -> Float Source #
Squared distance between two vectors
vectorDistance :: a -> a -> Float Source #
Distance between two vectors
vectorNormalize :: a -> a Source #
Normalize vector (same direction, magnitude 1)
vectorLerp :: a -> a -> Float -> a Source #
Lerp between two vectors
:: a | Vector to move |
-> a | Target vector |
-> Float | Max distance to move by |
-> a |
Move vector towards target
:: a | Vector to clamp |
-> a | Lower bound |
-> a | Upper bound |
-> a |
Clamp vector to range
Clamp the magnitude of a vector to a range
vectorMin :: a -> a -> a Source #
Min value for each pair of components
vectorMax :: a -> a -> a Source #
Max value for each pair of components
Instances
Vector2 math
vector2LineAngle :: Vector2 -> Vector2 -> Float Source #
Angle created by the line between two 2D vectors (parameters must be normalized)
Reflect 2D vector to normal
:: Vector2 | Normalized direction of the incoming ray |
-> Vector2 | Normalized normal vector of the interface of two optical media |
-> Float | Ratio of the refractive index of the medium from where the ray comes to the refractive index of the medium on the other side of the surface |
-> Vector2 |
Compute the direction of a refracted ray
Vector3 math
vector3Perpendicular :: Vector3 -> Vector3 Source #
Perpendicular to given 3D vector
vector3OrthoNormalize :: Vector3 -> Vector3 -> (Vector3, Vector3) Source #
Orthonormalize provided vectors. Makes vectors normalized and orthogonal to each other. Gram-Schmidt function implementation.
vector3RotateByQuaternion :: Vector3 -> Quaternion -> Vector3 Source #
Transform a 3D vector by quaternion rotation
vector3RotateByAxisAngle Source #
Rotate a 3D vector around an axis
:: Vector3 | Vector 1 |
-> Vector3 | Tangent for vector 1 |
-> Vector3 | Vector 2 |
-> Vector3 | Tangent for vector 2 |
-> Float | Interpolation amount |
-> Vector3 |
Cubic hermite interpolation between two vectors and their tangents as described in the GLTF 2.0 specification
Reflect 3D vector to normal
Compute barycenter coordinates (u, v, w) for a point with respect to a triangle. NOTE: Assumes the point is on the plane of the triangle.
Project a Vector3 from screen space into object space
:: Vector3 | Normalized direction of the incoming ray |
-> Vector3 | Normalized normal vector of the interface of two optical media |
-> Float | Ratio of the refractive index of the medium from where the ray comes to the refractive index of the medium on the other side of the surface |
-> Vector3 |
Compute the direction of a refracted ray
Matrix math
matrixToList :: Matrix -> [Float] Source #
Utility function
matrixFromList :: [Float] -> Matrix Source #
Utility function
matrixConstant :: Float -> Matrix Source #
Scalar to matrix (all elements are set to the scalar)
matrixDeterminant :: Matrix -> Float Source #
Compute matrix determinant
matrixTrace :: Matrix -> Float Source #
Trace of a matrix (sum of the values along the diagonal)
matrixTranspose :: Matrix -> Matrix Source #
Transpose a matrix
matrixInvert :: Matrix -> Matrix Source #
Invert a matrix
matrixIdentity :: Matrix Source #
Identity matrix
Translation matrix
Axis-angle rotation matrix (angle should be in radians)
matrixRotateX :: Float -> Matrix Source #
x-rotation matrix (angle should be in radians)
matrixRotateY :: Float -> Matrix Source #
y-rotation matrix (angle should be in radians)
matrixRotateZ :: Float -> Matrix Source #
z-rotation matrix (angle should be in radians)
matrixRotateXYZ :: Vector3 -> Matrix Source #
Euler angle xyz rotation matrix (angles should be in radians)
matrixRotateZYX :: Vector3 -> Matrix Source #
Euler angle zyx rotation matrix (angles should be in radians)
matrixScale :: Vector3 -> Matrix Source #
Scaling matrix
:: Float | Left edge distance |
-> Float | Right edge distance |
-> Float | Bottom edge distance |
-> Float | Top edge distance |
-> Float | Near clipping plane distance |
-> Float | Far clipping plane distance |
-> Matrix |
Frustum projection matrix
:: Float | y-fov angle (should be in radians) |
-> Float | Aspect ratio |
-> Float | Near clipping plane distance |
-> Float | Far clipping plane distance |
-> Matrix |
Perspective projection matrix
:: Float | Left edge distance |
-> Float | Right edge distance |
-> Float | Bottom edge distance |
-> Float | Top edge distance |
-> Float | Near clipping plane distance |
-> Float | Far clipping plane distance |
-> Matrix |
Orthographic projection matrix
Camera look-at matrix (view matrix)
matrixDecompose :: Matrix -> (Vector3, Quaternion, Vector3) Source #
Decompose a transformation matrix into its rotational, translational and scaling components
Quaternion math
quaternionIdentity :: Quaternion Source #
Identity quaternion
quaternionInvert :: Quaternion -> Quaternion Source #
Invert a quaternion
quaternionMultiply :: Quaternion -> Quaternion -> Quaternion Source #
Multiply two quaternions
quaternionNormalize :: Quaternion -> Quaternion Source #
Normalize a quaternion (alias for vectorNormalize
)
:: Quaternion | Lerp start value |
-> Quaternion | Lerp end value |
-> Float | Lerp amount |
-> Quaternion |
Lerp between two quaternions (alias for quaternionLerp
)
:: Quaternion | Lerp start value |
-> Quaternion | Lerp end value |
-> Float | Lerp amount |
-> Quaternion |
Slerp-optimized interpolation between two quaternions
:: Quaternion | Lerp start value |
-> Quaternion | Lerp end value |
-> Float | Lerp amount |
-> Quaternion |
Spherical linear interpolation between two quaternions
quaternionCubicHermiteSpline Source #
:: Quaternion | Quaternion 1 |
-> Quaternion | Out tangent 1 |
-> Quaternion | Quaternion 2 |
-> Quaternion | In tangent 2 |
-> Float | Interpolation amount |
-> Quaternion |
Quaternion cubic spline interpolation using the Cubic Hermite Spline algorithm as described in the GLTF 2.0 specification
quaternionFromVector3ToVector3 :: Vector3 -> Vector3 -> Quaternion Source #
Quaternion based on the rotation between two vectors
quaternionFromMatrix :: Matrix -> Quaternion Source #
Create a quaternion from a rotation matrix
quaternionToMatrix :: Quaternion -> Matrix Source #
Create a rotation matrix from a quaternion
quaternionFromAxisAngle Source #
:: Vector3 | Rotation axis |
-> Float | Angle in radians |
-> Quaternion |
Create a quaternion for an angle and axis
quaternionToAxisAngle :: Quaternion -> (Vector3, Float) Source #
Convert a quaternion to axis-angle representation
:: Float | Pitch |
-> Float | Yaw |
-> Float | Roll |
-> Quaternion |
Create a quaternion from Euler angles (ZYX rotation order, angles should be in radians)
quaternionToEuler :: Quaternion -> Vector3 Source #
Convert a quaternion to Euler angle representation (Vector3 roll pitch yaw, all angles in radians)
quaternionTransform :: Quaternion -> Matrix -> Quaternion Source #
Transform a quaternion given a transformation matrix