#vector-math #vector #maths

vector3

A library for dealing with 3D mathematical vectors

7 stable releases

2.0.1 Dec 22, 2024
1.1.4 Mar 15, 2022
1.1.3 Mar 13, 2022

#449 in Math

Download history 4/week @ 2024-09-15 21/week @ 2024-09-22 16/week @ 2024-09-29 2/week @ 2024-10-06 10/week @ 2024-10-20 4/week @ 2024-10-27 4/week @ 2024-11-03 17/week @ 2024-11-17 6/week @ 2024-11-24 9/week @ 2024-12-01 32/week @ 2024-12-08 12/week @ 2024-12-15 179/week @ 2024-12-22

224 downloads per month

Custom license

11KB
266 lines

vector3

What is it?

vector3 is a rust library for dealing with 3D mathematical vectors.

What does it do?

vector3 allows for creation of three dimensional vectors as well as performing arithmetic operaitons on them, some of which are: addition, subtraction, multiplication, division of the magnitude, cross and dot prodcuts and normalizaton.

How do I get started?

Make sure you have a project set up using cargo then:

If using cargo-edit:

cd into the said project directory and execute

cargo add vector3

If not using cargo-edit:

Go to this crate's crates.io page and look right

Examples:

let a = Vector3::from_i32(1, 2, 3);
let b = Vector3::from_i32(1,2,3);

assert_eq!(a.dot(&b), 14.0);
let a = Vector3::from_i32(1, 2, 3);
let b = Vector3::from_i32(3, 2, 1);

assert_eq!(a.cross(&b), Vector3::from_i32(-4, 8, -4));
let a = Vector3::from_i32(1, 0, 0);
let b = Vector3::from_i32(0, 0, 1);

assert_eq!(a.angle(b) * (180.0 / PI), 90.0);

No runtime deps