summaryrefslogtreecommitdiff
path: root/engine/src/vector.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/vector.rs')
-rw-r--r--engine/src/vector.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/engine/src/vector.rs b/engine/src/vector.rs
index 1d2ea93..5b7779c 100644
--- a/engine/src/vector.rs
+++ b/engine/src/vector.rs
@@ -124,6 +124,17 @@ impl Vec3<f32>
{
(self.x * rhs.x) + (self.y * rhs.y) + (self.z * rhs.z)
}
+
+ /// Returns a direction vector from the specified angle (in degrees).
+ #[must_use]
+ pub fn direction_from_angle(pitch_degs: f32, yaw_degs: f32) -> Self
+ {
+ Self {
+ x: yaw_degs.to_radians().cos() * pitch_degs.to_radians().cos(),
+ y: pitch_degs.to_radians().sin(),
+ z: yaw_degs.to_radians().sin() * pitch_degs.to_radians().cos(),
+ }
+ }
}
impl<Value> Vec3<Value>