example/
example.rs

1use vec3D::Vec3D;
2
3fn main() {
4    // Simple initialisation
5    let vec1 = Vec3D::new(1.0, 2.0, 3.0);
6    println!("{}", vec1);               // Prints: "[1.0, 2.0, 3.0]"
7
8    // Operator overloads for clean code
9    let vec2 = Vec3D::new(3.0, 4.0, 5.0);
10    let vec3 = vec1 + vec2;
11    println!("{}", vec3);               // Prints: "[4.0, 6.0, 8.0]"
12
13    let vec4 = vec3 * 2.0;
14    println!("{}", vec4);               // Prints: "[8.0, 12.0, 16.0]"
15
16    // Common vector operations
17    let dot_product = vec3.dot(vec4);
18    println!("{}", dot_product);        // Prints: "232"
19
20    let vec5 = Vec3D::new(1.0, 0.0, 0.0);
21    let vec6 = Vec3D::new(0.0, 1.0, 0.0);
22    let cross_product = vec5.cross(vec6);
23    println!("{}", cross_product);      // Prints: "[0.0, 0.0, 1.0]"
24
25    // Plus initialisations from spherical/cylindrical coordinates, rotations and more
26}