QAngle: Difference between revisions
Jump to navigation
Jump to search
Note:Z is clamped to +/-50 for player viewangles.
TomEdwards (talk | contribs) mNo edit summary |
TomEdwards (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
'''QAngle''' is a C++ class that represents a three-dimensional Euler angle. Each QAngle contains three [[vec_t]] ordinates: | '''QAngle''' is a C++ class that represents a three-dimensional Euler angle. Each QAngle contains three [[vec_t]] ordinates: | ||
* X | * '''X''' pitch +down/-up | ||
* Y | * '''Y''' yaw +left/-right | ||
* Z | * '''Z''' roll +right/-left | ||
(45,10,0) means 45° down, 10° left and 0° roll. | <code>(45,10,0)</code> means 45° down, 10° left and 0° roll. | ||
{{note|Z is clamped to +/-50 for player viewangles.}} | {{note|Z is clamped to +/-50 for player viewangles.}} | ||
Line 15: | Line 15: | ||
* The classname QAngle is case-sensitive. | * The classname QAngle is case-sensitive. | ||
* You could also assign to the X, Y and Z member variables separately. | * You could also assign to the X, Y and Z member variables separately. | ||
* The prefix ang (or sometimes just a) identifies the variable as an angle. | * The prefix <code>ang</code> (or sometimes just <code>a</code>) identifies the variable as an angle. | ||
== Converting to a vector == | == Converting to a vector == |
Revision as of 06:10, 7 June 2009
QAngle is a C++ class that represents a three-dimensional Euler angle. Each QAngle contains three vec_t ordinates:
- X pitch +down/-up
- Y yaw +left/-right
- Z roll +right/-left
(45,10,0)
means 45° down, 10° left and 0° roll.

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.
Converting to a 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);