pub struct Vec3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
impl Vec3 {
pub fn new(x: f64, y: f64, z: f64) -> Vec3 {
Vec3 { x, y, z }
}
pub fn norm(&self) -> f64 {
(self.x.powi(2) + self.y.powi(2) + self.z.powi(2)).sqrt()
}
pub fn dot(&self, rhs: &Vec3) -> f64 {
(self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z)
}
pub fn cross(&self, rhs: &Vec3) -> Vec3 {
Vec3::new((self.y * rhs.z) - (self.z * rhs.y),
(self.z * rhs.x) - (self.x * rhs.z),
(self.x * rhs.y) - (self.y * rhs.x))
}
}