vext

Crates.iovext
lib.rsvext
version0.1.20
sourcesrc
created_at2019-05-24 19:30:25.93567
updated_at2019-05-26 18:56:27.614308
descriptionBasic Physics 'Vector' Library
homepage
repository
max_upload_size
id136761
size9,834
Dawson Frakes (dawsonfrakes)

documentation

README

vext

Basic Physics 'Vector' Library

Usage

Add the following to your Cargo.toml:

[dependencies]
vext = "0.1.20"

and this to your crate root:

extern crate vext;

Example

use vext::*;

fn main() {
    let mut vec2 = Vector2::new(25.0, 50.0);
    vec2.set(125.0, vec2.y()); // Sets x to 125 and y to previous y value: 50

    let (x, _y) = vec2.get();

    let vec3 = Vector3::new(x, 25.0, 100.0);

    let vec3_2 = vec2.to_v3(5.0); // Creates Vector3 with xy of v2 and z of 5
    let mut vec3_3 = Vector3::from(vec2); // Creates a Vector3 with xy of v2 and z of 0
    vec3_3.set(vec3_3.x(), vec3_3.y(), 35.0); // Sets xy to previous and z to 35

    let vec3_4 = vec3_2 + vec3_3;
    let direction = vec3_4.normalize(); // Get pointing direction of Vector3

    let string: String = direction.to_string(); // Not required for println!() but you can to_string() if needed
    println!("vec2: {}\nvec3: {}\nmagnitude: {}", vec2, vec3, string); // Prints whole vectors
    println!("vec3_2 x: {}", vec3_2.x()); // Prints single vector magnitude
}
Commit count: 0

cargo fmt