Crates.io | vector3 |
lib.rs | vector3 |
version | 1.1.4 |
source | src |
created_at | 2022-03-13 17:18:54.873594 |
updated_at | 2022-03-15 01:53:41.780396 |
description | A library for dealing with 3D mathematical vectors |
homepage | |
repository | https://github.com/DigitalCyan/vector3 |
max_upload_size | |
id | 549295 |
size | 6,833 |
vector3
is a rust library for dealing with 3D mathematical vectors.
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.
Make sure you have a project set up using cargo
then:
cargo-edit
:cd
into the said project directory and execute
cargo add vector
cargo-edit
:Go to this crate's crates.io page and look right
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);