Quaternion.AxisAngle not the same as quaternion.ToAngleAxis()??

Confused with this,why?(0.1, 0.0, 0.8, 0.6) and (-0.1, 0.0, -1.0, -0.1)?why not the same?

  Vector3 localRoll;
        float angle;
        Quaternion quaternion = transform.localRotation;
        // Quaternion  quaternion = new Quaternion();
        quaternion.ToAngleAxis(out angle, out localRoll);

        // Debug.Log("start euler:"+obj.localEulerAngles);
        // Debug.Log(localRoll);
        Debug.Log(Quaternion.AxisAngle(localRoll, angle) + " " + quaternion);//out put is (0.1, 0.0, 0.8, 0.6)  (-0.1, 0.0, -1.0, -0.1)

Quaternion.AxisAngle was made obsolete a while ago, because it used radians, which non-math-inclined people find daunting. Use Quaternion.AngleAxis instead.

I agree that changes like this have made the Quaternion even more confusing than it already was.

They should’ve made a different Quaternion struct that operates exclusively with degrees, and make them implicitly cast between each other when needed. Or at least a separate set of extensions methods operating on the same object type.

anyway, your test should give you the same result if you do

quaternion.ToAngleAxis(out angle, out localRoll);
Debug.Log(Quaternion.AxisAngle(localRoll, angle * Mathf.Deg2Rad);
1 Like

confused with this,they should the same rule to use,also degree or also radians

It’s an older version that was left in only because some people’s programs rely on it.
But you’re not supposed to use it now that it is known to be obsolete, because at some point in the future, it might be removed entirely.

That’s what ‘obsolete’ means in programming terms.

1 Like