Define a Torus region.

I mean, actual core memories are usually toroids, so...
This commit is contained in:
2020-11-29 17:43:32 -08:00
parent abac9be49c
commit 9dddf6406a
2 changed files with 53 additions and 0 deletions

View File

@@ -179,6 +179,16 @@ impl Vec3 {
z: self.z / other.z,
}
}
pub fn with_mag(&self, new_mag: Flt) -> Vec3 {
if new_mag == 0.0 {
// avoid div-by-zero if self.mag() == 0 and new_mag == 0
Self::zero()
} else {
let scale = Real::from_inner(new_mag) / self.mag();
self.clone() * scale.into_inner()
}
}
}
impl Into<(Flt, Flt, Flt)> for Vec3 {