QAngle: Difference between revisions
| TomEdwards (talk | contribs)  (→Orientation:  Hammer confuses things even more) | TomEdwards (talk | contribs)  mNo edit summary | ||
| Line 7: | Line 7: | ||
| * '''Z''' roll +right/-left | * '''Z''' roll +right/-left | ||
| <code>(45,10,0)</code> means 45°  | <code>(-45,10,0)</code> means 45° up, 10° left and 0° roll. | ||
| {{tip|The axes are sometimes called rX, rY and rZ to distinguish them from [[vector]] axes.}} | {{tip|The axes are sometimes called rX, rY and rZ to distinguish them from [[vector]] axes.}} | ||
| Line 15: | Line 15: | ||
| == Declaration == | == Declaration == | ||
|   QAngle angMyAngle = QAngle(45,10,0); |   QAngle angMyAngle = QAngle(-45,10,0); | ||
| * The classname QAngle is case-sensitive. | * The classname QAngle is case-sensitive. | ||
| Line 25: | Line 25: | ||
| Confusingly, Source's rY and rZ angle axes respectively point down the ''Z'' and ''Y'' vector axes - the opposite of what might be expected. X and rX are the same, however. | Confusingly, Source's rY and rZ angle axes respectively point down the ''Z'' and ''Y'' vector axes - the opposite of what might be expected. X and rX are the same, however. | ||
| Even ''more'' confusingly, Hammer lists rotation axes as Y, Z, X! This is completely wrong, but luckily they are just labels: the values are stored in a single string (e.g. "10  | Even ''more'' confusingly, Hammer lists rotation axes as Y, Z, X! This is completely wrong, but luckily they are just labels: the values are stored in a single string (e.g. "-45 10 0") and interpreted when they reach C++ code as being rX rY rZ. | ||
| {{todo|Are angles typically abs or local?}} | {{todo|Are angles typically abs or local?}} | ||
Revision as of 07:25, 7 June 2009
QAngle is a C++ class that represents a three-dimensional Euler angle, offset from the Z axis. Each QAngle contains three vec_t rotation values:
- X pitch +down/-up
- Y yaw +left/-right
- Z roll +right/-left
(-45,10,0) means 45° up, 10° left and 0° roll.
 Tip:The axes are sometimes called rX, rY and rZ to distinguish them from vector axes.
Tip:The axes are sometimes called rX, rY and rZ to distinguish them from vector axes. Note:Z is clamped to +/-50 for player viewangles.
Note:Z is clamped to +/-50 for player viewangles.Declaration
QAngle angMyAngle = QAngle(-45,10,0);
- The classname QAngle is case-sensitive.
- You could also assign to the X, Y and Z member variables separately.
- The prefix ang(or sometimes justa) identifies the variable as an angle.
Orientation
Confusingly, Source's rY and rZ angle axes respectively point down the Z and Y vector axes - the opposite of what might be expected. X and rX are the same, however.
Even more confusingly, Hammer lists rotation axes as Y, Z, X! This is completely wrong, but luckily they are just labels: the values are stored in a single string (e.g. "-45 10 0") and interpreted when they reach C++ code as being rX rY rZ.
Converting from Vector
As there is no specific datadesc keyfield for angles, one chosen in Hammer will arrive as a vector. Its ordinates will represent degrees of rotation and not coordinates so it must be fixed up before use:
QAngle angMyAngle = QAngle(vecFromHammer.x, vecFromHammer.y, vecFromHammer.z);
// Conversion back to a vector, if required
AngleVectors(angMyAngle, &vecFromHammer);