Raxol.Animation.Physics.Vector (Raxol v0.3.0)

View Source

3D vector implementation for physics simulations.

Provides basic vector operations needed for physics calculations.

Summary

Functions

Adds two vectors.

Calculates the angle between two vectors in radians.

Calculates the cross product of two vectors.

Calculates the distance between two points represented as vectors.

Calculates the dot product of two vectors.

Creates a vector from spherical coordinates.

Performs linear interpolation between two vectors.

Calculates the magnitude (length) of a vector.

Returns the negation of the vector.

Creates a new vector with the specified components.

Normalizes a vector (makes it unit length).

Multiplies a vector by a scalar.

Subtracts the second vector from the first.

Converts the vector to a string representation.

Types

t()

@type t() :: %Raxol.Animation.Physics.Vector{x: float(), y: float(), z: float()}

Functions

add(v1, v2)

Adds two vectors.

angle(v1, v2)

Calculates the angle between two vectors in radians.

cross(v1, v2)

Calculates the cross product of two vectors.

distance(v1, v2)

Calculates the distance between two points represented as vectors.

dot(v1, v2)

Calculates the dot product of two vectors.

from_spherical(radius, theta, phi)

Creates a vector from spherical coordinates.

lerp(v1, v2, t)

Performs linear interpolation between two vectors.

magnitude(v)

Calculates the magnitude (length) of a vector.

negate(v)

Returns the negation of the vector.

new(x, y, z \\ 0.0)

Creates a new vector with the specified components.

normalize(v)

Normalizes a vector (makes it unit length).

scale(v, scalar)

Multiplies a vector by a scalar.

subtract(v1, v2)

Subtracts the second vector from the first.

to_string(v)

Converts the vector to a string representation.