Exercise: Geometry
We will create a few utility functions for 3-dimensional geometry, representing a point as [f64;3]. It is up to you to determine the function signatures.
1. ```
// Calculate the magnitude of a vector by summing the squares of its coordinates
```
2. ```
// and taking the square root. Use the `sqrt()` method to calculate the square
```
3. ```
// root, like `v.sqrt()`.
```
5. ```
fn magnitude(...) -> f64 {
```
6. ```
todo!()
```
7. ```
}
```
9. ```
// Normalize a vector by calculating its magnitude and dividing all of its
```
10. ```
// coordinates by that magnitude.
```
12. ```
fn normalize(...) {
```
13. ```
todo!()
```
14. ```
}
```
16. ```
// Use the following `main` to test your work.
```
18. ```
fn main() {
```
19. ```
println!("Magnitude of a unit vector: {}", magnitude(&[0.0, 1.0, 0.0]));
```
21. ```
let mut v = [1.0, 2.0, 9.0];
```
22. ```
println!("Magnitude of {v:?}: {}", magnitude(&v));
```
23. ```
normalize(&mut v);
```
24. ```
println!("Magnitude of {v:?} after normalization: {}", magnitude(&v));
```
25. ```
}
```
