View Source SpaceDust.Math.Vector (Space Dust v0.1.0)

Vector operations

Summary

Functions

add two 3D vectors

angle between two 3D vectors

cross product of two 3D vectors

dot product of two 3D vectors

create a 3D vector from a list

magnitude of a 3D vector

normalize a 3D vector

rotate a 3D vector by a 3x3 matrix

scale a 3D vector

subtract two 3D vectors

Types

vector()

@type vector() :: %SpaceDust.Math.Vector.Vector3D{
  x: number(),
  y: number(),
  z: number()
}

Functions

add(a, b)

@spec add(vector(), vector()) :: vector()

add two 3D vectors

angle(a, b)

@spec angle(vector(), vector()) :: number()

angle between two 3D vectors

cross(a, b)

@spec cross(vector(), vector()) :: vector()

cross product of two 3D vectors

dot(a, b)

@spec dot(vector(), vector()) :: number()

dot product of two 3D vectors

fromList(list)

@spec fromList([number()]) :: vector()

create a 3D vector from a list

magnitude(a)

@spec magnitude(vector()) :: number()

magnitude of a 3D vector

normalize(a)

@spec normalize(vector()) :: vector()

normalize a 3D vector

rotate(a, m)

@spec rotate(vector(), SpaceDust.Math.Matrix.matrix()) :: vector()

rotate a 3D vector by a 3x3 matrix

scale(a, s)

@spec scale(vector(), number()) :: vector()

scale a 3D vector

subtract(a, b)

@spec subtract(vector(), vector()) :: vector()

subtract two 3D vectors