Maybe it's something we've fixed?  I added your code:

        Quaternion qNewOrientation;
        Vector axis;
        float angle;

        AngleQuaternion( QAngle(0,90,0), qNewOrientation );
        QuaternionAxisAngle( qNewOrientation, axis, angle );
        Msg("Q:Axis: %.2f %.2f %.2f :: %.3f\n", VectorExpand(axis),
angle );
        // If I pass QAngle(0,90,0)  I will get 0.707106 or 90 angle

        AngleQuaternion( QAngle(0,270,0), qNewOrientation );
        QuaternionAxisAngle( qNewOrientation, axis, angle );
        Msg("Q:Axis: %.2f %.2f %.2f :: %.3f\n", VectorExpand(axis),
angle );
        // If I pass QAngle(0,270,0)  I also get 0.707106 or 90 angle

And I get these results:
Q:Axis: 0.00 0.00 1.00 :: 90.000
Q:Axis: -0.00 0.00 1.00 :: -90.000

But I'm running the orange box sdk.

Here's the code for QuaternionAxisAngle()
void QuaternionAxisAngle( const Quaternion &q, Vector &axis, float
&angle )
{
        angle = RAD2DEG(2 * acos(q.w));
        if ( angle > 180 )
        {
                angle -= 360;
        }
        axis.x = q.x;
        axis.y = q.y;
        axis.z = q.z;
        VectorNormalize( axis );
}

Is that the same code you're using?

Jay


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Joel R.
Sent: Monday, October 01, 2007 3:06 AM
To: hlcoders
Subject: [hlcoders] Quaternion to AxisAngle

--
[ Picked text/plain from multipart/alternative ]
I'm having a problem getting the correct angle.  I seem to be stuck
getting
an angle between 0 and 180, due to the W value always being 0.0 to 1.0
and
not -1.0 to 1.0.

---CODE---
------------------------------------------------------------------------
----------------
Quaternion qNewOrientation;
Vector axis;
float angle;

AngleQuaternion( m_angSpawnAngle, qNewOrientation );
QuaternionAxisAngle( qNewOrientation, axis, angle );
------------------------------------------------------------------------
----------------

If I pass QAngle(0,90,0)  I will get 0.707106 or 90 angle
If I pass QAngle(0,270,0)  I also get 0.707106 or 90 angle

The latter is suppose to be negative.  When I revert the quaternion back
to
a QAngle it gets the orientation correctly.
The formula QuaternionAxisAngle uses is correct because websites show
the
same algorithm used.
Anyone out there familiar with Quaternions know how I could possibly
solve
this? Thanks in advance!
--

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to