On this page:
_  float3
_  float16
Clamp
Lerp
Normalize
Remap
Wrap
Float  Equals
Vector2Zero
Vector2One
Vector2Add
Vector2Add  Value
Vector2Subtract
Vector2Subtract  Value
Vector2Length
Vector2Length  Sqr
Vector2Dot  Product
Vector2Distance
Vector2Distance  Sqr
Vector2Angle
Vector2Line  Angle
Vector2Scale
Vector2Multiply
Vector2Negate
Vector2Divide
Vector2Normalize
Vector2Transform
Vector2Lerp
Vector2Reflect
Vector2Min
Vector2Max
Vector2Rotate
Vector2Move  Towards
Vector2Invert
Vector2Clamp
Vector2Clamp  Value
Vector2Equals
Vector2Refract
Vector3Zero
Vector3One
Vector3Add
Vector3Add  Value
Vector3Subtract
Vector3Subtract  Value
Vector3Scale
Vector3Multiply
Vector3Cross  Product
Vector3Perpendicular
Vector3Length
Vector3Length  Sqr
Vector3Dot  Product
Vector3Distance
Vector3Distance  Sqr
Vector3Angle
Vector3Negate
Vector3Divide
Vector3Normalize
Vector3Project
Vector3Reject
Vector3Ortho  Normalize
Vector3Transform
Vector3Rotate  By  Quaternion
Vector3Rotate  By  Axis  Angle
Vector3Move  Towards
Vector3Lerp
Vector3Cubic  Hermite
Vector3Reflect
Vector3Min
Vector3Max
Vector3Barycenter
Vector3Unproject
Vector3To  Float  V
Vector3Invert
Vector3Clamp
Vector3Clamp  Value
Vector3Equals
Vector3Refract
Vector4Zero
Vector4One
Vector4Add
Vector4Add  Value
Vector4Subtract
Vector4Subtract  Value
Vector4Length
Vector4Length  Sqr
Vector4Dot  Product
Vector4Distance
Vector4Distance  Sqr
Vector4Scale
Vector4Multiply
Vector4Negate
Vector4Divide
Vector4Normalize
Vector4Min
Vector4Max
Vector4Lerp
Vector4Move  Towards
Vector4Invert
Vector4Equals
Matrix  Determinant
Matrix  Trace
Matrix  Transpose
Matrix  Invert
Matrix  Identity
Matrix  Add
Matrix  Subtract
Matrix  Multiply
Matrix  Translate
Matrix  Rotate
Matrix  Rotate  X
Matrix  Rotate  Y
Matrix  Rotate  Z
Matrix  Rotate  XYZ
Matrix  Rotate  ZYX
Matrix  Scale
Matrix  Frustum
Matrix  Perspective
Matrix  Ortho
Matrix  Look  At
Matrix  To  Float  V
Quaternion  Add
Quaternion  Add  Value
Quaternion  Subtract
Quaternion  Subtract  Value
Quaternion  Identity
Quaternion  Length
Quaternion  Normalize
Quaternion  Invert
Quaternion  Multiply
Quaternion  Scale
Quaternion  Divide
Quaternion  Lerp
Quaternion  Nlerp
Quaternion  Slerp
Quaternion  Cubic  Hermite  Spline
Quaternion  From  Vector3To  Vector3
Quaternion  From  Matrix
Quaternion  To  Matrix
Quaternion  From  Axis  Angle
Quaternion  To  Axis  Angle
Quaternion  From  Euler
Quaternion  To  Euler
Quaternion  Transform
Quaternion  Equals
Matrix  Decompose
8.17.0.1

5 Raymath🔗ℹ

 (require raylib/raymath/unsafe) package: raylib

Manually written bindings for Raylib’s Raymath module.

These are marked as unsafe because safety cannot be guaranteed, but you are very unlikely to experience undefined behaviour using this.

value

_float3 : ctype?

value

_float16 : ctype?

Struct-wrapped float arrays of 3 and 16 elements respectively.

These are converted to and from flvector?s of the given length.

procedure

(Clamp value min max)  _float

  value : _float
  min : _float
  max : _float
Clamp float value

procedure

(Lerp start end amount)  _float

  start : _float
  end : _float
  amount : _float
Calculate linear interpolation between two floats

procedure

(Normalize value start end)  _float

  value : _float
  start : _float
  end : _float
Normalize input value within input range

procedure

(Remap value    
  inputStart    
  inputEnd    
  outputStart    
  outputEnd)  _float
  value : _float
  inputStart : _float
  inputEnd : _float
  outputStart : _float
  outputEnd : _float
Remap input value within input range to output range

procedure

(Wrap value min max)  _float

  value : _float
  min : _float
  max : _float
Wrap input value from min to max

procedure

(FloatEquals x y)  _int

  x : _float
  y : _float
Check whether two given floats are almost equal

procedure

(Vector2Zero)  _Vector2

Vector with components value 0.0f

procedure

(Vector2One)  _Vector2

Vector with components value 1.0f

procedure

(Vector2Add v1 v2)  _Vector2

  v1 : _Vector2
  v2 : _Vector2
Add two vectors (v1 + v2)

procedure

(Vector2AddValue v add)  _Vector2

  v : _Vector2
  add : _float
Add vector and float value

procedure

(Vector2Subtract v1 v2)  _Vector2

  v1 : _Vector2
  v2 : _Vector2
Subtract two vectors (v1 - v2)

procedure

(Vector2SubtractValue v sub)  _Vector2

  v : _Vector2
  sub : _float
Subtract vector by float value

procedure

(Vector2Length v)  _float

  v : _Vector2
Calculate vector length

procedure

(Vector2LengthSqr v)  _float

  v : _Vector2
Calculate vector square length

procedure

(Vector2DotProduct v1 v2)  _float

  v1 : _Vector2
  v2 : _Vector2
Calculate two vectors dot product

procedure

(Vector2Distance v1 v2)  _float

  v1 : _Vector2
  v2 : _Vector2
Calculate distance between two vectors

procedure

(Vector2DistanceSqr v1 v2)  _float

  v1 : _Vector2
  v2 : _Vector2
Calculate square distance between two vectors

procedure

(Vector2Angle v1 v2)  _float

  v1 : _Vector2
  v2 : _Vector2
Calculate angle between two vectors NOTE: Angle is calculated from origin point (0, 0)

procedure

(Vector2LineAngle start end)  _float

  start : _Vector2
  end : _Vector2
Calculate angle defined by a two vectors line NOTE: Parameters need to be normalized Current implementation should be aligned with glm::angle

procedure

(Vector2Scale v scale)  _Vector2

  v : _Vector2
  scale : _float
Scale vector (multiply by value)

procedure

(Vector2Multiply v1 v2)  _Vector2

  v1 : _Vector2
  v2 : _Vector2
Multiply vector by vector

procedure

(Vector2Negate v)  _Vector2

  v : _Vector2
Negate vector

procedure

(Vector2Divide v1 v2)  _Vector2

  v1 : _Vector2
  v2 : _Vector2
Divide vector by vector

procedure

(Vector2Normalize v)  _Vector2

  v : _Vector2
Normalize provided vector

procedure

(Vector2Transform v mat)  _Vector2

  v : _Vector2
  mat : _Matrix
Transforms a Vector2 by a given Matrix

procedure

(Vector2Lerp v1 v2 amount)  _Vector2

  v1 : _Vector2
  v2 : _Vector2
  amount : _float
Calculate linear interpolation between two vectors

procedure

(Vector2Reflect v normal)  _Vector2

  v : _Vector2
  normal : _Vector2
Calculate reflected vector to normal

procedure

(Vector2Min v1 v2)  _Vector2

  v1 : _Vector2
  v2 : _Vector2
Get min value for each pair of components

procedure

(Vector2Max v1 v2)  _Vector2

  v1 : _Vector2
  v2 : _Vector2
Get max value for each pair of components

procedure

(Vector2Rotate v angle)  _Vector2

  v : _Vector2
  angle : _float
Rotate vector by angle

procedure

(Vector2MoveTowards v target maxDistance)  _Vector2

  v : _Vector2
  target : _Vector2
  maxDistance : _float
Move Vector towards target

procedure

(Vector2Invert v)  _Vector2

  v : _Vector2
Invert the given vector

procedure

(Vector2Clamp v min max)  _Vector2

  v : _Vector2
  min : _Vector2
  max : _Vector2
Clamp the components of the vector between min and max values specified by the given vectors

procedure

(Vector2ClampValue v min max)  _Vector2

  v : _Vector2
  min : _float
  max : _float
Clamp the magnitude of the vector between two min and max values

procedure

(Vector2Equals p q)  _int

  p : _Vector2
  q : _Vector2
Check whether two given vectors are almost equal

procedure

(Vector2Refract v n r)  _Vector2

  v : _Vector2
  n : _Vector2
  r : _float
Compute the direction of a refracted ray v: normalized direction of the incoming ray n: normalized normal vector of the interface of two optical media r: 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

procedure

(Vector3Zero)  _Vector3

Vector with components value 0.0f

procedure

(Vector3One)  _Vector3

Vector with components value 1.0f

procedure

(Vector3Add v1 v2)  _Vector3

  v1 : _Vector3
  v2 : _Vector3
Add two vectors

procedure

(Vector3AddValue v add)  _Vector3

  v : _Vector3
  add : _float
Add vector and float value

procedure

(Vector3Subtract v1 v2)  _Vector3

  v1 : _Vector3
  v2 : _Vector3
Subtract two vectors

procedure

(Vector3SubtractValue v sub)  _Vector3

  v : _Vector3
  sub : _float
Subtract vector by float value

procedure

(Vector3Scale v scalar)  _Vector3

  v : _Vector3
  scalar : _float
Multiply vector by scalar

procedure

(Vector3Multiply v1 v2)  _Vector3

  v1 : _Vector3
  v2 : _Vector3
Multiply vector by vector

procedure

(Vector3CrossProduct v1 v2)  _Vector3

  v1 : _Vector3
  v2 : _Vector3
Calculate two vectors cross product

procedure

(Vector3Perpendicular v)  _Vector3

  v : _Vector3
Calculate one vector perpendicular vector

procedure

(Vector3Length v)  _float

  v : _Vector3
Calculate vector length

procedure

(Vector3LengthSqr v)  _float

  v : _Vector3
Calculate vector square length

procedure

(Vector3DotProduct v1 v2)  _float

  v1 : _Vector3
  v2 : _Vector3
Calculate two vectors dot product

procedure

(Vector3Distance v1 v2)  _float

  v1 : _Vector3
  v2 : _Vector3
Calculate distance between two vectors

procedure

(Vector3DistanceSqr v1 v2)  _float

  v1 : _Vector3
  v2 : _Vector3
Calculate square distance between two vectors

procedure

(Vector3Angle v1 v2)  _float

  v1 : _Vector3
  v2 : _Vector3
Calculate angle between two vectors

procedure

(Vector3Negate v)  _Vector3

  v : _Vector3
Negate provided vector (invert direction)

procedure

(Vector3Divide v1 v2)  _Vector3

  v1 : _Vector3
  v2 : _Vector3
Divide vector by vector

procedure

(Vector3Normalize v)  _Vector3

  v : _Vector3
Normalize provided vector

procedure

(Vector3Project v1 v2)  _Vector3

  v1 : _Vector3
  v2 : _Vector3
Calculate the projection of the vector v1 on to v2

procedure

(Vector3Reject v1 v2)  _Vector3

  v1 : _Vector3
  v2 : _Vector3
Calculate the rejection of the vector v1 on to v2

procedure

(Vector3OrthoNormalize v1 v2)  _void

  v1 : (_pointer-to_Vector3)
  v2 : (_pointer-to_Vector3)
Orthonormalize provided vectors Makes vectors normalized and orthogonal to each other Gram-Schmidt function implementation

procedure

(Vector3Transform v mat)  _Vector3

  v : _Vector3
  mat : _Matrix
Transforms a Vector3 by a given Matrix

procedure

(Vector3RotateByQuaternion v q)  _Vector3

  v : _Vector3
  q : _Quaternion
Transform a vector by quaternion rotation

procedure

(Vector3RotateByAxisAngle v axis angle)  _Vector3

  v : _Vector3
  axis : _Vector3
  angle : _float
Rotates a vector around an axis

procedure

(Vector3MoveTowards v target maxDistance)  _Vector3

  v : _Vector3
  target : _Vector3
  maxDistance : _float
Move Vector towards target

procedure

(Vector3Lerp v1 v2 amount)  _Vector3

  v1 : _Vector3
  v2 : _Vector3
  amount : _float
Calculate linear interpolation between two vectors

procedure

(Vector3CubicHermite v1    
  tangent1    
  v2    
  tangent2    
  amount)  _Vector3
  v1 : _Vector3
  tangent1 : _Vector3
  v2 : _Vector3
  tangent2 : _Vector3
  amount : _float
Calculate cubic hermite interpolation between two vectors and their tangents as described in the GLTF 2.0 specification: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#interpolation-cubic

procedure

(Vector3Reflect v normal)  _Vector3

  v : _Vector3
  normal : _Vector3
Calculate reflected vector to normal

procedure

(Vector3Min v1 v2)  _Vector3

  v1 : _Vector3
  v2 : _Vector3
Get min value for each pair of components

procedure

(Vector3Max v1 v2)  _Vector3

  v1 : _Vector3
  v2 : _Vector3
Get max value for each pair of components

procedure

(Vector3Barycenter p a b c)  _Vector3

  p : _Vector3
  a : _Vector3
  b : _Vector3
  c : _Vector3
Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c) NOTE: Assumes P is on the plane of the triangle

procedure

(Vector3Unproject source projection view)  _Vector3

  source : _Vector3
  projection : _Matrix
  view : _Matrix
Projects a Vector3 from screen space into object space NOTE: We are avoiding calling other raymath functions despite available

procedure

(Vector3ToFloatV v)  _float3

  v : _Vector3
Get Vector3 as float array

procedure

(Vector3Invert v)  _Vector3

  v : _Vector3
Invert the given vector

procedure

(Vector3Clamp v min max)  _Vector3

  v : _Vector3
  min : _Vector3
  max : _Vector3
Clamp the components of the vector between min and max values specified by the given vectors

procedure

(Vector3ClampValue v min max)  _Vector3

  v : _Vector3
  min : _float
  max : _float
Clamp the magnitude of the vector between two values

procedure

(Vector3Equals p q)  _int

  p : _Vector3
  q : _Vector3
Check whether two given vectors are almost equal

procedure

(Vector3Refract v n r)  _Vector3

  v : _Vector3
  n : _Vector3
  r : _float
Compute the direction of a refracted ray v: normalized direction of the incoming ray n: normalized normal vector of the interface of two optical media r: 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

procedure

(Vector4Zero)  _Vector4

procedure

(Vector4One)  _Vector4

procedure

(Vector4Add v1 v2)  _Vector4

  v1 : _Vector4
  v2 : _Vector4

procedure

(Vector4AddValue v add)  _Vector4

  v : _Vector4
  add : _float

procedure

(Vector4Subtract v1 v2)  _Vector4

  v1 : _Vector4
  v2 : _Vector4

procedure

(Vector4SubtractValue v add)  _Vector4

  v : _Vector4
  add : _float

procedure

(Vector4Length v)  _float

  v : _Vector4

procedure

(Vector4LengthSqr v)  _float

  v : _Vector4

procedure

(Vector4DotProduct v1 v2)  _float

  v1 : _Vector4
  v2 : _Vector4

procedure

(Vector4Distance v1 v2)  _float

  v1 : _Vector4
  v2 : _Vector4
Calculate distance between two vectors

procedure

(Vector4DistanceSqr v1 v2)  _float

  v1 : _Vector4
  v2 : _Vector4
Calculate square distance between two vectors

procedure

(Vector4Scale v scale)  _Vector4

  v : _Vector4
  scale : _float

procedure

(Vector4Multiply v1 v2)  _Vector4

  v1 : _Vector4
  v2 : _Vector4
Multiply vector by vector

procedure

(Vector4Negate v)  _Vector4

  v : _Vector4
Negate vector

procedure

(Vector4Divide v1 v2)  _Vector4

  v1 : _Vector4
  v2 : _Vector4
Divide vector by vector

procedure

(Vector4Normalize v)  _Vector4

  v : _Vector4
Normalize provided vector

procedure

(Vector4Min v1 v2)  _Vector4

  v1 : _Vector4
  v2 : _Vector4
Get min value for each pair of components

procedure

(Vector4Max v1 v2)  _Vector4

  v1 : _Vector4
  v2 : _Vector4
Get max value for each pair of components

procedure

(Vector4Lerp v1 v2 amount)  _Vector4

  v1 : _Vector4
  v2 : _Vector4
  amount : _float
Calculate linear interpolation between two vectors

procedure

(Vector4MoveTowards v target maxDistance)  _Vector4

  v : _Vector4
  target : _Vector4
  maxDistance : _float
Move Vector towards target

procedure

(Vector4Invert v)  _Vector4

  v : _Vector4
Invert the given vector

procedure

(Vector4Equals p q)  _int

  p : _Vector4
  q : _Vector4
Check whether two given vectors are almost equal

procedure

(MatrixDeterminant mat)  _float

  mat : _Matrix
Compute matrix determinant

procedure

(MatrixTrace mat)  _float

  mat : _Matrix
Get the trace of the matrix (sum of the values along the diagonal)

procedure

(MatrixTranspose mat)  _Matrix

  mat : _Matrix
Transposes provided matrix

procedure

(MatrixInvert mat)  _Matrix

  mat : _Matrix
Invert provided matrix

procedure

(MatrixIdentity)  _Matrix

Get identity matrix

procedure

(MatrixAdd left right)  _Matrix

  left : _Matrix
  right : _Matrix
Add two matrices

procedure

(MatrixSubtract left right)  _Matrix

  left : _Matrix
  right : _Matrix
Subtract two matrices (left - right)

procedure

(MatrixMultiply left right)  _Matrix

  left : _Matrix
  right : _Matrix
Get two matrix multiplication NOTE: When multiplying matrices... the order matters!

procedure

(MatrixTranslate x y z)  _Matrix

  x : _float
  y : _float
  z : _float
Get translation matrix

procedure

(MatrixRotate axis angle)  _Matrix

  axis : _Vector3
  angle : _float
Create rotation matrix from axis and angle NOTE: Angle should be provided in radians

procedure

(MatrixRotateX angle)  _Matrix

  angle : _float
Get x-rotation matrix NOTE: Angle must be provided in radians

procedure

(MatrixRotateY angle)  _Matrix

  angle : _float
Get y-rotation matrix NOTE: Angle must be provided in radians

procedure

(MatrixRotateZ angle)  _Matrix

  angle : _float
Get z-rotation matrix NOTE: Angle must be provided in radians

procedure

(MatrixRotateXYZ angle)  _Matrix

  angle : _Vector3
Get xyz-rotation matrix NOTE: Angle must be provided in radians

procedure

(MatrixRotateZYX angle)  _Matrix

  angle : _Vector3
Get zyx-rotation matrix NOTE: Angle must be provided in radians

procedure

(MatrixScale x y z)  _Matrix

  x : _float
  y : _float
  z : _float
Get scaling matrix

procedure

(MatrixFrustum left    
  right    
  bottom    
  top    
  nearPlane    
  farPlane)  _Matrix
  left : _double
  right : _double
  bottom : _double
  top : _double
  nearPlane : _double
  farPlane : _double
Get perspective projection matrix

procedure

(MatrixPerspective fovY    
  aspect    
  nearPlane    
  farPlane)  _Matrix
  fovY : _double
  aspect : _double
  nearPlane : _double
  farPlane : _double
Get perspective projection matrix NOTE: Fovy angle must be provided in radians

procedure

(MatrixOrtho left    
  right    
  bottom    
  top    
  nearPlane    
  farPlane)  _Matrix
  left : _double
  right : _double
  bottom : _double
  top : _double
  nearPlane : _double
  farPlane : _double
Get orthographic projection matrix

procedure

(MatrixLookAt eye target up)  _Matrix

  eye : _Vector3
  target : _Vector3
  up : _Vector3
Get camera look-at matrix (view matrix)

procedure

(MatrixToFloatV mat)  _float16

  mat : _Matrix
Get float array of matrix data

procedure

(QuaternionAdd q1 q2)  _Quaternion

  q1 : _Quaternion
  q2 : _Quaternion
Add two quaternions

procedure

(QuaternionAddValue q add)  _Quaternion

  q : _Quaternion
  add : _float
Add quaternion and float value

procedure

(QuaternionSubtract q1 q2)  _Quaternion

  q1 : _Quaternion
  q2 : _Quaternion
Subtract two quaternions

procedure

(QuaternionSubtractValue q sub)  _Quaternion

  q : _Quaternion
  sub : _float
Subtract quaternion and float value

Get identity quaternion

procedure

(QuaternionLength q)  _float

  q : _Quaternion
Computes the length of a quaternion

procedure

(QuaternionNormalize q)  _Quaternion

  q : _Quaternion
Normalize provided quaternion

procedure

(QuaternionInvert q)  _Quaternion

  q : _Quaternion
Invert provided quaternion

procedure

(QuaternionMultiply q1 q2)  _Quaternion

  q1 : _Quaternion
  q2 : _Quaternion
Calculate two quaternion multiplication

procedure

(QuaternionScale q mul)  _Quaternion

  q : _Quaternion
  mul : _float
Scale quaternion by float value

procedure

(QuaternionDivide q1 q2)  _Quaternion

  q1 : _Quaternion
  q2 : _Quaternion
Divide two quaternions

procedure

(QuaternionLerp q1 q2 amount)  _Quaternion

  q1 : _Quaternion
  q2 : _Quaternion
  amount : _float
Calculate linear interpolation between two quaternions

procedure

(QuaternionNlerp q1 q2 amount)  _Quaternion

  q1 : _Quaternion
  q2 : _Quaternion
  amount : _float
Calculate slerp-optimized interpolation between two quaternions

procedure

(QuaternionSlerp q1 q2 amount)  _Quaternion

  q1 : _Quaternion
  q2 : _Quaternion
  amount : _float
Calculates spherical linear interpolation between two quaternions

procedure

(QuaternionCubicHermiteSpline q1    
  outTangent1    
  q2    
  inTangent2    
  t)  _Quaternion
  q1 : _Quaternion
  outTangent1 : _Quaternion
  q2 : _Quaternion
  inTangent2 : _Quaternion
  t : _float
Calculate quaternion cubic spline interpolation using Cubic Hermite Spline algorithm as described in the GLTF 2.0 specification: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#interpolation-cubic

procedure

(QuaternionFromVector3ToVector3 from to)  _Quaternion

  from : _Vector3
  to : _Vector3
Calculate quaternion based on the rotation from one vector to another

procedure

(QuaternionFromMatrix mat)  _Quaternion

  mat : _Matrix
Get a quaternion for a given rotation matrix

procedure

(QuaternionToMatrix q)  _Matrix

  q : _Quaternion
Get a matrix for a given quaternion

procedure

(QuaternionFromAxisAngle axis angle)  _Quaternion

  axis : _Vector3
  angle : _float
Get rotation quaternion for an angle and axis NOTE: Angle must be provided in radians

procedure

(QuaternionToAxisAngle q outAxis outAngle)  _void

  q : _Quaternion
  outAxis : (_pointer-to_Vector3)
  outAngle : (_pointer-to_float)
Get the rotation angle and axis for a given quaternion

procedure

(QuaternionFromEuler pitch yaw roll)  _Quaternion

  pitch : _float
  yaw : _float
  roll : _float
Get the quaternion equivalent to Euler angles NOTE: Rotation order is ZYX

procedure

(QuaternionToEuler q)  _Vector3

  q : _Quaternion
Get the Euler angles equivalent to quaternion (roll, pitch, yaw) NOTE: Angles are returned in a Vector3 struct in radians

procedure

(QuaternionTransform q mat)  _Quaternion

  q : _Quaternion
  mat : _Matrix
Transform a quaternion given a transformation matrix

procedure

(QuaternionEquals p q)  _int

  p : _Quaternion
  q : _Quaternion
Check whether two given quaternions are almost equal

procedure

(MatrixDecompose mat    
  translation    
  rotation    
  scale)  _void
  mat : _Matrix
  translation : (_pointer-to_Vector3)
  rotation : (_pointer-to_Quaternion)
  scale : (_pointer-to_Vector3)
Decompose a transformation matrix into its rotational, translational and scaling components