mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 11:06:11 -10:00
Use lookAt's float degree constant, and wrap the pitch as vanilla does
Entity.lookAt multiplies by 57.2957763671875 rather than Math.toDegrees. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
a2ed6c2882
commit
4cbcd2e4fc
1 file changed
+4
-2
@@ -1617,8 +1617,10 @@ fn text_error(key: &str, args: &[Text]) -> horizon_client::command::CommandError
|
||||
pub(super) fn look_at(from: [f64; 3], to: [f64; 3]) -> [f32; 2] {
|
||||
let (dx, dy, dz) = (to[0] - from[0], to[1] - from[1], to[2] - from[2]);
|
||||
let horizontal = (dx * dx + dz * dz).sqrt();
|
||||
let pitch = (-(dy.atan2(horizontal).to_degrees())) as f32;
|
||||
let yaw = (dz.atan2(dx).to_degrees() - 90.0) as f32;
|
||||
// `Entity.lookAt` turns radians to degrees with the float constant
|
||||
// `57.2957763671875`, not `Math.toDegrees`.
|
||||
let pitch = wrap_degrees((-(dy.atan2(horizontal) * 57.295_776_367_187_5)) as f32);
|
||||
let yaw = (dz.atan2(dx) * 57.295_776_367_187_5) as f32 - 90.0;
|
||||
[wrap_degrees(yaw), pitch]
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user