Basic Physics 'Vector' Library * Documentation
Add the following to your Cargo.toml
:
toml
[dependencies]
vext = "0.1.16"
and this to your crate root:
rust
extern crate vext;
```rust extern crate vext;
fn main() { let vec2 = Vector2::new(25, 50); vec2.set(125, vec2.y()); // Sets x to 125 and y to previous y value: 50
let (x, y) = vec2.get();
let vec3 = Vector3::new(x, 25, 100);
let vec3_2 = vec2.to_v3(5); // Creates Vector3 with xy of v2 and z of 5
let vec3_3 = Vector3::from(vec2); // Creates a Vector3 with xy of v2 and z of 0
vec3_3.set(vec_3.x(), vec_3.y(), 35); // Sets xy to previous and z to 35
let vec3_4 = vec3_2 + vec3_3;
let magnitude = vec3_4.normalize(); // Get pointing direction of Vector3
} ```