h-raylib-4.6.0.3: Raylib bindings for Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Raylib.Util.Math

Synopsis

Utility constants

Float math

clamp Source #

Arguments

:: Float

Value to clamp

-> Float

Lower bound

-> Float

Upper bound

-> Float 

Clamp float to range

lerp Source #

Arguments

:: Float

Starting value

-> Float

Ending value

-> Float

Lerp amount

-> Float 

Calculate linear interpolation between two floats

normalize Source #

Arguments

:: Float

Value to normalize

-> Float

Starting value of range

-> Float

Ending value of range

-> Float 

Normalize input value within input range

remap Source #

Arguments

:: Float

Input value

-> Float

Input range start

-> Float

Input range end

-> Float

Output range start

-> Float

Output range end

-> Float 

Remap input value within input range to output range

wrap Source #

Arguments

:: Float

Input value

-> Float

Min value

-> Float

Max value

-> Float 

Wrap input value from min to max

floatEquals :: Float -> Float -> Bool Source #

Check if two floats are close to equal

General vector math

class Vector a where Source #

Minimal complete definition

asList, fromList

Methods

asList :: a -> [Float] Source #

List representation of a vector

fromList :: [Float] -> a Source #

Vector representation of a list

(|+|) :: a -> a -> a Source #

Vector-vector addition

(|-|) :: a -> a -> a Source #

Vector-vector subtraction

(|+) :: a -> Float -> a Source #

Vector-scalar addition

(|-) :: a -> Float -> a Source #

Vector-scalar subtraction

(|*|) :: a -> a -> a Source #

Vector-vector multiplication

(|/|) :: a -> a -> a Source #

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 :: a Source #

Zero vector

one :: a Source #

One vector

constant :: Float -> a Source #

Scalar to vector (all elements are set to the scalar)

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

vectorMoveTowards Source #

Arguments

:: a

Vector to move

-> a

Target vector

-> Float

Max distance to move by

-> a 

Move vector towards target

vectorClamp Source #

Arguments

:: a

Vector to clamp

-> a

Lower bound

-> a

Upper bound

-> a 

Clamp vector to range

vectorClampValue Source #

Arguments

:: a

Vector to clamp

-> Float

Lower bound

-> Float

Upper bound

-> a 

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

Instances details
Vector Vector2 Source # 
Instance details

Defined in Raylib.Util.Math

Vector Vector3 Source # 
Instance details

Defined in Raylib.Util.Math

Vector Vector4 Source # 
Instance details

Defined in Raylib.Util.Math

Vector2 math

vector2Angle :: Vector2 -> Vector2 -> Float Source #

Angle between two 2D vectors

vector2LineAngle :: Vector2 -> Vector2 -> Float Source #

Angle created by the line between two 2D vectors (parameters must be normalized)

vector2Transform :: Vector2 -> Matrix -> Vector2 Source #

Transform a 2D vector by the given matrix

vector2Reflect Source #

Arguments

:: Vector2

Input vector

-> Vector2

Normal vector

-> Vector2 

Reflect 2D vector to normal

vector2Rotate :: Vector2 -> Float -> Vector2 Source #

Rotate 2D vector by angle

Vector3 math

vector3CrossProduct :: Vector3 -> Vector3 -> Vector3 Source #

3D vector cross-product

vector3Perpendicular :: Vector3 -> Vector3 Source #

Perpendicular to given 3D vector

vector3Angle :: Vector3 -> Vector3 -> Float Source #

Angle between two 3D vectors

vector3OrthoNormalize :: Vector3 -> Vector3 -> (Vector3, Vector3) Source #

Orthonormalize provided vectors. Makes vectors normalized and orthogonal to each other. Gram-Schmidt function implementation.

vector3Transform :: Vector3 -> Matrix -> Vector3 Source #

Transform a 3D vector by a matrix

vector3RotateByQuaternion :: Vector3 -> Quaternion -> Vector3 Source #

Transform a 3D vector by quaternion rotation

vector3RotateByAxisAngle Source #

Arguments

:: Vector3

Vector to rotate

-> Vector3

Axis to rotate around

-> Float

Angle to rotate by

-> Vector3 

Rotate a 3D vector around an axis

vector3Reflect Source #

Arguments

:: Vector3

Input vector

-> Vector3

Normal vector

-> Vector3 

Reflect 3D vector to normal

vector3Barycenter Source #

Arguments

:: Vector3

Input point

-> (Vector3, Vector3, Vector3)

Triangle vertices

-> Vector3 

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.

vector3Unproject Source #

Arguments

:: Vector3

Vector to unproject

-> Matrix

Projection matrix

-> Matrix

View matrix

-> Vector3 

Project a Vector3 from screen space into object space

vector3Refract Source #

Arguments

:: 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

matrixAdd :: Matrix -> Matrix -> Matrix Source #

Add two matrices

matrixSubtract :: Matrix -> Matrix -> Matrix Source #

Subtract two matrices

matrixMultiply :: Matrix -> Matrix -> Matrix Source #

Multiply two matrices (order matters!)

matrixTranslate Source #

Arguments

:: Float

x translation

-> Float

y translation

-> Float

z translation

-> Matrix 

Translation matrix

matrixRotate Source #

Arguments

:: Vector3

Axis to rotate around

-> Float

Angle to rotate by

-> 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

matrixFrustum Source #

Arguments

:: 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

matrixPerspective Source #

Arguments

:: 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

matrixOrtho Source #

Arguments

:: 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

matrixLookAt Source #

Arguments

:: Vector3

Camera position

-> Vector3

Camera target

-> Vector3

World up vector

-> Matrix 

Camera look-at matrix (view matrix)

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)

quaternionLerp Source #

Arguments

:: Quaternion

Lerp start value

-> Quaternion

Lerp end value

-> Float

Lerp amount

-> Quaternion 

Lerp between two quaternions (alias for quaternionLerp)

quaternionNLerp Source #

Arguments

:: Quaternion

Lerp start value

-> Quaternion

Lerp end value

-> Float

Lerp amount

-> Quaternion 

Slerp-optimized interpolation between two quaternions

quaternionSLerp Source #

Arguments

:: Quaternion

Lerp start value

-> Quaternion

Lerp end value

-> Float

Lerp amount

-> Quaternion 

Spherical linear interpolation between two quaternions

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 #

Arguments

:: 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

quaternionFromEuler Source #

Arguments

:: 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