vec3-rs 0.5.1

minimal 3d vector implementation
Documentation

vec3-rs

This crate provides a simple implementation of 3D vectors in Rust.

Supports any numeric type trough num-traits.

Example

type Vector3 = vec3_rs::Vector3<f64>;

fn main() {
    let v1 = Vector3::new(1, 2.5, 3);
    let v2 = Vector3::from([9.0, 1.0, 4.0]);

    let v3 = (v1 + v2) - (v1 - v2);
    let v3 = v3.cross(v2);
    let v3 = v3 * v3.dot(v1);
    let v3 = v3 * 10.0 / 3.2;
    let v3 = (v3 + Vector3::one()).normalized();
    let v3 = v3.lerp(Vector3::zero(), 0.25);
    let v3 = v3.floor() + Vector3::one();

    println!("{v3}");
    println!("{}", v3.angle(Vector3::z_axis()));
    println!("{}", v3.fuzzy_equal(Vector3::z_axis(), 2.0));
}