modules coord2d

Crate Status docs.rs Crates.io

rust lib for coordinate in 2d system

example Coord

```rust use coord2d::*; fn main () { let a: coords::Coord = newcoord!(1, 2.0); let o: coords::Coord = newcoord!(2.0); let x: i32 = 3; let y: f64 = 3.0; let b: coords::Coord = new_coord!(x, y);

// math let c: coords::Coord = a + b; let d: coords::Coord = a - c; let e: coords::Coord = a * d; let f: coords::Coord = o / a;

// to vec let g: Vec = a.to_vec();

// to tuple let i: (i32, i32) = c.to_tuple();

// split let (r, o) = e.to_tuple();

println!("let a: coord::Coord = newcoord!(1, 2.0); | {:?}", a); println!("let o: coord::Coord = newcoord!(2.0); | {:?}", o); println!( "\nlet (x , y) = (3.0, 3);\nlet b: coords::Coord = newcoord!(x, y); | {:?}", b ); println!("\nlet c: coord::Coord = a + b; | {:?}", c); println!("\nlet d: coord::Coord = a - c; | {:?}", d); println!("\nlet e: coord::Coord = a * d; | {:?}", e); println!("\nlet f: coord::Coord = a / a; | {:?}", f); println!("\n let g: Vec = a.tovec(); {:?}", g); println!("\n let i: (i32, i32) = c.totuple(); | {:?}", i); println!("\n let (r, o) = e.totuple(); r={}, o={}", r, o); } ```

example Vectors

```rust use coord2d::*;

fn main () { let a: coords::Coord = newcoord!(2.5, 3.3); let o: coords::Coord = newcoord!(2.5); let x: i32 = 3; let y: f32 = 3.0; let b: coords::Coord = new_coord!(x, y);

let d: coords::Coord = a - b; let e: coords::Coord = a * d;

let h: vectors::Vector = newvector!(); let f: vectors::Vector = newvector!(o); let l: vectors::Vector = new_vector!(a, e);

let m: vectors::Vector = h + l; let s: vectors::Vector = h + l; let w: vectors::Vector = m + h; let t: vectors::Vector = h + s;

let vec: Vec = s.tovec(); let tup: (coords::Coord, coords::Coord, f64) = s.totuple(); let mag: f64 = t.getmagnitude(); let mid: coords::Coord = m.getmidpoint(); println!("\nlet h:vectors::Vector = newvector!(); | {:?}", h); println!("\nlet f:vectors::Vector = newvector!(); | {:?}", f); println!("\nlet l:vectors::Vector = newvector!(a, e); | {:?}", l); println!("\nlet m = h + l; | {:?}", m); println!("\nlet s = h + l; | {:?}", s); println!("\nlet w = m + h; | {:?}", w); println!("\nlet t = h + s; | {:?}", t); println!("\nlet mag = t.getmagnitude(); | {}", mag); println!("\nlet vec = s.tovec(); | {:?}", vec); println!("\nlet tup = s.totuple(); | {:?}", tup); println!("\nlet mid: coords::Coord = m.get_midpoint(); | {:?}", mid);

} ```

example Debug

```rust use coord2d::*;

fn main () { let a: coords::Coord = newcoord!(1, 2.0); let x: i32 = 3.0; let y: i32 = 3; let b: coords::Coord = newcoord!(x, y);

let l:vectors::Vector = new_vector!(a, b);

debug::debug(a);
debug::debug(l);

let type_a = debug::type_of(a);
let type_h = debug::type_of(h);

println!("{}", type_a);
println!("{}", type_h);

} ```

TO DO

Any suggestion please open issue or do a pull request

stats

abdellatif-dev's GitHub stats

Top Langs

you contact us over contact@abdellatifdev.xyz