viva_math/vec4

4-D vector operations.

Used for RGBA colors, homogeneous coordinates and quaternions (when the fourth component is treated as w/real).

Types

pub type Vec4 {
  Vec4(x: Float, y: Float, z: Float, w: Float)
}

Constructors

  • Vec4(x: Float, y: Float, z: Float, w: Float)

Values

pub fn add(a: Vec4, b: Vec4) -> Vec4
pub fn clamp(v: Vec4, lo: Float, hi: Float) -> Vec4
pub fn distance(a: Vec4, b: Vec4) -> Float
pub fn dot(a: Vec4, b: Vec4) -> Float
pub fn is_close(a: Vec4, b: Vec4, tol: Float) -> Bool
pub fn length(v: Vec4) -> Float

Length using two-level hypot to avoid overflow at extreme scales.

pub fn length_squared(v: Vec4) -> Float
pub fn lerp(a: Vec4, b: Vec4, t: Float) -> Vec4
pub fn multiply(a: Vec4, b: Vec4) -> Vec4

Hadamard (component-wise) product.

pub fn negate(v: Vec4) -> Vec4
pub fn normalize(v: Vec4) -> Vec4
pub fn scale(v: Vec4, s: Float) -> Vec4
pub fn splat(value: Float) -> Vec4
pub fn sub(a: Vec4, b: Vec4) -> Vec4
pub fn zero() -> Vec4
Search Document