You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

UrhoSharp中Quaternion转Euler Angle角度符号反转问题咨询

Hey there! Let's break down why you're seeing that -45° instead of +45° when converting your Quaternions to Euler angles in UrhoSharp — this is all about engine-specific conventions, not a mistake in your code or math!

1. UrhoSharp's Coordinate System & Rotation Direction Rules

First, UrhoSharp uses a left-handed coordinate system by default (Y-axis up, X-axis right, Z-axis forward). For rotation directions:

  • When you use Quaternion.FromAxisAngle(Vector3.UnitY, +45f), the +45f angle refers to a clockwise rotation around the Y-axis (use the left-hand rule: point your left thumb up along the Y-axis, and your curled fingers show the positive rotation direction).
  • But when you call ToEulerAngles(), the Y-axis component (called "yaw") of the returned Euler angles uses the opposite direction convention: positive values represent counterclockwise rotations (from the same top-down view of the Y-axis).

So a clockwise 45° rotation (what your quaternion represents) directly translates to a counterclockwise -45° in the Euler angle output — that's the core reason for the sign flip.

2. The Quaternion Constructor Behavior

Your second example new Quaternion(0f, +45f, 0f) follows the same logic. This constructor takes three values that map to pitch (X-axis), yaw (Y-axis), roll (Z-axis) Euler angles. When you pass +45f as the yaw value, it creates a quaternion for a clockwise 45° Y-axis rotation — which, again, converts back to -45° when you call ToEulerAngles() due to the direction convention mismatch in the conversion method.

A Quick Fix If You Need Positive Angles

If you want the Euler angle output to match the sign you used to create the quaternion, you can simply invert the Y-axis component of the result:

var correctedYaw = -outputAngle.Y;
// correctedYaw will be +45° for both your examples

This works because you're just flipping the direction convention to match your original input's sign.

内容的提问来源于stack exchange,提问作者Soumya Kar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:49:12