Crate veccentric[][src]

Expand description

Tiny 2D vector library. Inspired by p5.js’s p5.Vector.

The main type, Vecc<T>, is a generic struct implementing many useful traits and operator overloading. Fecc is a type alias for Vecc<f64>. It has an extended API, heavily inspired by p5.Vector.

Features

The random feature enables additional methods on Fecc: from_rng, from_seed, from_entropy.

The all feature enables just random.

Notes

float_cmp::assert_approx_eq is used in some examples.

Examples

use veccentric::Fecc;

let a = Fecc::new(3.0, 4.0);
assert_approx_eq!(f64, a.mag(), 5.0);

let five_a = a * 5.0;
assert_approx_eq!(f64, five_a.mag(), 25.0);

let b = Fecc::new(-3.0, 0.0);
let c = a + b; // (0.0, 4.0)
assert_approx_eq!(f64, c.angle(), PI / 2.0);

For more examples, go to Vecc’s docs or to the repository.

Re-exports

pub use angle::Angle;
pub use angle::Angular;
pub use fecc::Fecc;
pub use vecc::Vecc;

Modules

Angles.

Implementation of Fecc - the alias for Vecc<f64>.

Generic vector with two components.