1use crate::math::mul_add;
2
3#[derive(Debug, Clone, Copy, PartialEq)]
5pub struct Vec3d {
6 pub x: f64,
8 pub y: f64,
10 pub z: f64,
12}
13
14impl Vec3d {
15 pub const fn new(x: f64, y: f64, z: f64) -> Self {
17 Self { x, y, z }
18 }
19
20 pub fn distance(&self, other: &Self) -> f64 {
22 let x_diff = self.x - other.x;
23 let y_diff = self.y - other.y;
24 let z_diff = self.z - other.z;
25
26 mul_add(x_diff, x_diff, mul_add(y_diff, y_diff, z_diff * z_diff))
27 }
28}
29
30#[cfg(test)]
31#[path = "./vec3d_tests.rs"]
32mod tests;