5 releases

0.2.5 Dec 29, 2024
0.2.4 Dec 29, 2024
0.2.3 Feb 6, 2022
0.1.2 Feb 5, 2022

#414 in Math

Download history 78/week @ 2024-12-23 89/week @ 2024-12-30 10/week @ 2025-01-06 2/week @ 2025-01-13 2/week @ 2025-02-10 2/week @ 2025-02-17

414 downloads per month

MIT license

18KB
288 lines

Useful vector math implementations

Examples

use vecs::Vec2;

fn main() {
    // creates 2 Vec2 objects
    let v1 = Vec2::new(12., 6.);
    let v2 = Vec2::new(17., 9.);

    // adds the vectors together
    let v3 = v1 + v2;

    // prints (29, 15) to the console
    println!("{}", v3);
}
use vecs::Vec3;

fn main() {
    // creates 2 Vec3 objects
    let v1 = Vec3::new(2., 6., 7.);
    let v2 = Vec3::new(5., 3., 8.);

    // gets the 2 vectors cross product
    let v3 = v1.cross(v2);

    // prints (27, 19, -24) to the console
    println!("{}", v3);
}

Crate API

a simple vector math library

examples

use vecs::Vec2;

fn main() {
    // creates 2 Vec2 objects
    let v1 = Vec2::new(12., 6.);
    let v2 = Vec2::new(17., 9.);

    // adds the vectors together
    let v3 = v1 + v2;

    // prints (29, 15) to the console
    println!("{}", v3);
}
use vecs::Vec3;

fn main() {
    // creates 2 Vec3 objects
    let v1 = Vec3::new(2., 6., 7.);
    let v2 = Vec3::new(5., 3., 8.);

    // gets the 2 vectors cross product
    let v3 = v1.cross(v2);

    // prints (27, 19, -24) to the console
    println!("{}", v3);
}

Dependencies

~150KB