Crate vectorlib

source ·
Expand description

vectorlib

vectorlib is a library for mathematical vector operations. The implementation of the vectorlib librarry is meant for graphical vector operations. Design the library is inspired by a similar library in python pygame for the module pygame.math.vector, but far from being complete.

Features

  • Generic format for the vector
  • Logging and error handling, checkvectorResult for example.
  • Support traits for display in debugging mode.
  • Operators overloading for (+)/(-)/(/)/(*) for our vector.
  • Adding support for other vector methods - in progress

Modules

  • math::vector2d_module: Provides basic operations for 2D vectors.
  • math::vector2d_verbose_module: Provides verbose operations for 2D vectors.

Examples

use vectorlib::math::vector2d_module::Vector2d;
use vectorlib::math::vector2d_verbose_module::VerboseVector2d;
use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub};

let v = Vector2d::new(2.0, 3.0);
let w = Vector2d::new(4.0, 5.0);
let result = v + w;
let s2 = v + 5.0; // Accpet scalar
let s3 = v.add(w); // accept method .add(), .sub() ..etc.

println!("V: {v} and W: {w}");
println!("Result: {:?}", result);

//Accept a verbose vector for tracing drop objects (vectors)
let _u = VerboseVector2d::new(v, true);
// Check the test module to see the implementations of each method.

License

This library is licensed under the MIT License.

Modules