X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fcommon%2Fgeometry.rs;fp=src%2Fcommon%2Fgeometry.rs;h=ebf122a402171f3fe6f94a419c0dda0d45ad864c;hb=8065e2645a936275c7d69c6068d80ece598d6e57;hp=e46f23e6040fc9784b1e56dc700cf51dccb3a3c7;hpb=b5332019b30abd70698c9cdd7b7b9d42502681c2;p=kaka%2Frust-sdl-test.git diff --git a/src/common/geometry.rs b/src/common/geometry.rs index e46f23e..ebf122a 100644 --- a/src/common/geometry.rs +++ b/src/common/geometry.rs @@ -173,16 +173,21 @@ pub struct Radians(pub f64); impl Degrees { #[allow(dead_code)] - fn to_radians(&self) -> Radians { + pub fn to_radians(&self) -> Radians { Radians(self.0.to_radians()) } } impl Radians { #[allow(dead_code)] - fn to_degrees(&self) -> Degrees { + pub fn to_degrees(&self) -> Degrees { Degrees(self.0.to_degrees()) } + + /// Returns the reflection of the incident when mirrored along this angle. + pub fn mirror(&self, incidence: Radians) -> Radians { + Radians((std::f64::consts::PI + self.0 * 2.0 - incidence.0) % std::f64::consts::TAU) + } } ////////// INTERSECTION ////////////////////////////////////////////////////////