pub fn cross_product(&self, p: Self) -> f64 {
return self.x * p.y - self.y * p.x;
}
+
+ /// Returns the perpendicular projection of this vector on a line with the specified angle.
+ pub fn project_onto(&self, angle: Angle) -> Point<f64> {
+ let dot_product = self.length() * (self.to_angle() - angle).to_radians().cos();
+ Point::from(angle) * dot_product
+ }
}
macro_rules! impl_point_op {
pub fn mirror(&self, incidence: Angle) -> Angle {
Angle((std::f64::consts::PI + self.0 * 2.0 - incidence.0) % std::f64::consts::TAU)
}
+
+ pub fn reverse(&self) -> Angle {
+ Angle((self.0 + std::f64::consts::PI) % std::f64::consts::TAU)
+ }
}
impl PartialEq for Angle {