On this page:
_  float3
_  float16
Clamp
Lerp
Normalize
Remap
Vector2Zero
Vector2One
Vector2Add
Vector2Add  Value
Vector2Subtract
Vector2Subtract  Value
Vector2Length
Vector2Length  Sqr
Vector2Dot  Product
Vector2Distance
Vector2Angle
Vector2Scale
Vector2Multiply
Vector2Negate
Vector2Divide
Vector2Normalize
Vector2Lerp
Vector2Reflect
Vector2Rotate
Vector2Move  Towards
Vector3Zero
Vector3One
Vector3Add
Vector3Add  Value
Vector3Subtract
Vector3Subtract  Value
Vector3Scale
Vector3Multiply
Vector3Cross  Product
Vector3Perpendicular
Vector3Length
Vector3Length  Sqr
Vector3Dot  Product
Vector3Distance
Vector3Angle
Vector3Negate
Vector3Divide
Vector3Normalize
Vector3Ortho  Normalize
Vector3Transform
Vector3Rotate  By  Quaternion
Vector3Lerp
Vector3Reflect
Vector3Min
Vector3Max
Vector3Barycenter
Vector3Unproject
Vector3To  Float  V
Matrix  Determinant
Matrix  Trace
Matrix  Transpose
Matrix  Invert
Matrix  Normalize
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  Lerp
Quaternion  Nlerp
Quaternion  Slerp
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
8.12

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

(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

(Vector2Angle v1 v2)  _float

  v1 : _Vector2
  v2 : _Vector2
Calculate angle from two vectors in X-axis

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

(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

(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

(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

(Vector3Angle v1 v2)  _Vector2

  v1 : _Vector3
  v2 : _Vector3
Calculate angle between two vectors in XY and XZ

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

(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

(Vector3Lerp v1 v2 amount)  _Vector3

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

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

(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

(MatrixNormalize mat)  _Matrix

  mat : _Matrix
Normalize 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 (angle in radians)

procedure

(MatrixRotateY angle)  _Matrix

  angle : _float
Get y-rotation matrix (angle in radians)

procedure

(MatrixRotateZ angle)  _Matrix

  angle : _float
Get z-rotation matrix (angle in radians)

procedure

(MatrixRotateXYZ ang)  _Matrix

  ang : _Vector3
Get xyz-rotation matrix (angles in radians)

procedure

(MatrixRotateZYX ang)  _Matrix

  ang : _Vector3
Get zyx-rotation matrix (angles in radians)

procedure

(MatrixScale x y z)  _Matrix

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

procedure

(MatrixFrustum left right bottom top near far)  _Matrix

  left : _double
  right : _double
  bottom : _double
  top : _double
  near : _double
  far : _double
Get perspective projection matrix

procedure

(MatrixPerspective fovy aspect near far)  _Matrix

  fovy : _double
  aspect : _double
  near : _double
  far : _double
Get perspective projection matrix

NOTE: Angle should be provided in radians

procedure

(MatrixOrtho left right bottom top near far)  _Matrix

  left : _double
  right : _double
  bottom : _double
  top : _double
  near : _double
  far : _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

(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

(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)  
_Vector3 _float
  q : _Quaternion
Returns (values outAxis outAngle).

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