From 72dc5960d6963743fc7434ba2698fe844460a7d0 Mon Sep 17 00:00:00 2001 From: Sam <samuelkeiffer@gmail.com> Date: Fri, 15 Oct 2021 22:41:53 -0400 Subject: [PATCH] Correctly took dot product, switched to square root of dot product --- common/src/comp/ori.rs | 2 +- common/src/states/utils.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/comp/ori.rs b/common/src/comp/ori.rs index 4b4e90963e..7f3bb40198 100644 --- a/common/src/comp/ori.rs +++ b/common/src/comp/ori.rs @@ -208,7 +208,7 @@ impl Ori { if angle < PI { angle } else { TAU - angle } } - pub fn dot(self, other: Self) -> f32 { self.0.dot(other.0) } + pub fn dot(self, other: Self) -> f32 { self.look_vec().dot(other.look_vec()) } pub fn pitched_up(self, angle_radians: f32) -> Self { self.rotated(Quaternion::rotation_x(angle_radians)) diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 65a51b9a91..a296d51d63 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -406,7 +406,7 @@ pub fn handle_orientation( let rate = { // Angle factor used to keep turning rate approximately constant by // counteracting slerp turning more with a larger angle - let angle_factor = 2.0 / (1.0 - update.ori.dot(target_ori)); + let angle_factor = 2.0 / (1.0 - update.ori.dot(target_ori)).sqrt(); data.body.base_ori_rate() * efficiency * angle_factor }; update.ori = update