QAngle: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (Nesciuse moved page QAngle/en to QAngle without leaving a redirect: Move en subpage to basepage)
 
(91 intermediate revisions by 42 users not shown)
Line 1: Line 1:
[http://dolmen.downslip.info/ dolmen] [http://ers.misserve.info/ ers] [http://c-470-olympus.downslip.info/ c 470 olympus] [http://vietnam-73.indulger.info/ vietnam 73] [http://horse-sexy.downslip.info/ horse sexy] [http://sony-vaio-1gb-mb.misserve.info/ sony vaio 1gb mb] [http://radeon-x300-se.batswing.info/ radeon x300 se] [http://lui-lui-lui.downslip.info/ lui lui lui] [http://francois.stroam.info/ francois] [http://www-north-woods-lake-ca.batswing.info/ www north woods lake ca] [http://misserve.info/ misserve.info] [http://gourmet.misserve.info/ gourmet] [http://downslip.info/index6_666.html url] [http://fiat-croma-km0.unfeeble.info/ fiat croma km0] [http://samsung-sf-340.misserve.info/ samsung sf 340] [http://misserve.info/index8_250.html homepage] [http://i-know-what-you-want.unfeeble.info/ i know what you want] [http://burblers.info/index1_666.html page] [http://master-max-sm.wrawler.info/ master max sm] [http://wwww-porta-net.wrawler.info/ wwww porta net] [http://balzella.unfeeble.info/ balzella] [http://nefer-srl.batswing.info/ nefer srl] [http://fipa.stroam.info/ fipa] [http://free-codec-dvd.indulger.info/ free codec dvd] [http://dlt-40-80.downslip.info/ dlt 40 80] [http://trust-hires-wb-3400t.misserve.info/ trust hires wb 3400t] [http://filme.indulger.info/ filme] [http://downslip.info/index1_1000.html url] [http://new-goi-srl.wrawler.info/ new goi srl] [http://tru-lines.wrawler.info/ tru lines] [http://gps-geonav-4-c.unfeeble.info/ gps geonav 4 c] [http://laster.indulger.info/ laster] [http://downslip.info/index6_666.html url] [http://grand.wrawler.info/ grand] [http://hp-4100-cartucce.indulger.info/ hp 4100 cartucce] [http://barnaba.unfeeble.info/ barnaba] [http://porno-manga.wrawler.info/ porno manga] [http://vimet-spa.indulger.info/ vimet spa] [http://driv3er.stroam.info/ driv3er] [http://suse-9-1.indulger.info/ suse 9 1] [http://misserve.info/index2_666.html url] [http://download-real-player.batswing.info/ download real player] [http://zwijndrecht.misserve.info/ zwijndrecht] [http://unfeeble.info/index2_250.html link] [http://big-foot.wrawler.info/ big foot] [http://yahoo-toolbar.misserve.info/ yahoo toolbar] [http://batswing.info/index2_666.html home] [http://infostrada-adsl.stroam.info/ infostrada adsl] [http://online.unfeeble.info/ online] [http://transcend-flash.batswing.info/ transcend flash] [http://stroam.info/ stroam.info] [http://sdram-533-512.batswing.info/ sdram 533 512] [http://batswing.info/index5_666.html homepage] [http://july-taylor.indulger.info/ july taylor] [http://phantom-f12.burblers.info/ Phantom f12] [http://carmageddon-64.batswing.info/ carmageddon 64] [http://safe-from-harm.misserve.info/ safe from harm] [http://downslip.info/index3_1000.html homepage] [http://acer-mp3-1-gb.unfeeble.info/ acer mp3 1 gb] [http://gumus.batswing.info/ gumus] [http://nokia-route-66-mobile.burblers.info/ nokia route 66 mobile] [http://the-beatles.batswing.info/ the beatles] [http://wonder-9800.indulger.info/ wonder 9800] [http://unfeeble.info/index5_1000.html home] [http://lebazar.unfeeble.info/ lebazar] [http://hd-80g.downslip.info/ hd 80g] [http://downslip.info/index7_250.html page] [http://gifes.indulger.info/ gifes] [http://lcd-philips-190p5es.burblers.info/ lcd philips 190p5es] [http://euhm.unfeeble.info/ euhm] [http://easy-telecom.burblers.info/ easy telecom] [http://culo.misserve.info/ culo] [http://btu.batswing.info/ btu] [http://desktop-asus-amd-3000.indulger.info/ desktop asus amd 3000] [http://burblers.info/index0_666.html site] [http://sblocco-samsung.burblers.info/ sblocco samsung] [http://coeds.batswing.info/ coeds] [http://bolw-in-the-wind.stroam.info/ bolw in the wind] [http://c350-driver.unfeeble.info/ c350 driver] [http://downslip.info/index7_250.html page] [http://scauri.downslip.info/ scauri] [http://show-must-go-on.stroam.info/ show must go on] [http://ind.wrawler.info/ ind] [http://isdn-flat.downslip.info/ isdn flat] [http://tv-lcd-20-acer.unfeeble.info/ tv lcd 20 acer] [http://se-got-the-look.misserve.info/ se got the look] [http://fat-porno.downslip.info/ Fat porno] [http://ghosts-n-goblins.burblers.info/ ghosts n goblins] [http://dvd-con-hd.misserve.info/ dvd con hd] [http://www-astra-ro.wrawler.info/ www astra ro] [http://nou-ghe-n-e.wrawler.info/ nou ghe n e] [http://mp3-haiduci.unfeeble.info/ mp3 haiduci] [http://morgan.misserve.info/ morgan] [http://oroscopo-pesci.downslip.info/ oroscopo pesci] [http://indulger.info/ indulger.info] [http://dhoom-mp3.indulger.info/ dhoom mp3] [http://rock-tv-key.burblers.info/ rock tv key] [http://wrawler.info/ wrawler.info] [http://encalve.indulger.info/ encalve] [http://leonor-watling.batswing.info/ leonor watling]  
{{LanguageBar|title = QAngle}}
{| style="text-align:center"
 
! Description || Name || Value || Image || Code
{{toc-right}}
|-
 
|rowspan="3"| An angular world<br />orientation in degrees. || Pitch || Y
'''QAngle''' is a C++ class in [[Source]] that represents a three-dimensional [[Wikipedia: Extrinsic rotations|extrinsic Tait-Bryan rotations]] following the [[Wikipedia: Right-hand rule|right-hand rule]], offset from the cardinal [[Coordinates|Z axis]]. Each QAngle contains three [[vec t]] rotation values:  
|rowspan="3"| [[Image:Roll_pitch_yaw.gif]]
== ==
|rowspan="3"| <code>QAngle(y, z, x)</code>
=== X ===
|-
'''X''' pitch +down/-up
| Yaw || Z
=== Y ===
|-
'''Y''' yaw +left/-right
| Roll || X
=== Z ===
|}
'''Z''' roll +right/-left
[[Category:Glossary]] [[Category:Helpers]] [[Category:Level Design]]
 
<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.}}
 
{{note|Z is clamped to +/-50 for player viewangles.}}
 
== Declaration ==
 
QAngle angMyAngle = QAngle(-45,10,0);
 
* You could also assign to the X, Y and Z member variables separately.
* The prefix <code>ang</code> (or sometimes just <code>a</code>) identifies the variable as an angle.
 
== Orientation ==
 
To get a feeling for how a <code>QAngle([X], [Y], [Z])</code> works, imagine a first-person perspective:  
 
* Looking down or up corresponds to positive or negative [X]
* Looking left or right corresponds to positive or negative [Y]
* Tilting your head so your right or left ear faces the ground corresponds to positive or negative [Z]
 
To relate this back to vectors and coordinates: The values of [X], [Y], and [Z] correspond to a clockwise rotation (in degrees) around the [[Coordinates|absolute axes]]{{confirm}} y, z, and x, respectively.  
 
"Clockwise rotation" in an axis assumes the viewer is located at the origin looking in the positive direction of said axis.
 
=== Naming Conventions ===
 
Different fields use different naming conventions to describe these angles. To clear up any conflicting terms, short explanations are included below. Source Engine seems to draw its lingo from Aerospace Engineering.
 
'''Aerospace Engineering'''
 
{{Expand|When imagining a plane, pitch moves the nose up and down, yaw moves the nose left and right, and roll causes one wing to move up and the other wing to move down.
[[Wikipedia: Aircraft principal axes|In Aerospace Engineering]], this system is also referred to as Euler angles if — unlike QAngles — the axes rotate along. See "Mathematics" for clarification.}}
 
'''Mathematics'''
 
{{Expand| Strictly speaking, QAngles would be defined as [[Wikipedia: Extrinsic rotations|extrinsic Tait-Bryan rotations]] following the [[Wikipedia: Right-hand rule|right-hand rule]]. The terms "Tait-Bryan angles" and "Euler angles" are sometimes used interchangeably however. Breaking down this name into digestible chunks:
 
* The difference between [[Wikipedia: Extrinsic rotations|intrinsic and extrinsic rotations]], is that with the former, each rotation shifts the axes along with it
* The difference between [[Wikipedia: Euler angles|proper Euler angles and Tait-Bryan angles]], is that the former rotates twice around one axis and once around another (alternatingly), while the latter rotates once around all three axes
* The [[Wikipedia: right-hand rule|right-hand rule]] states that if the thumb of one's right hand is pointing along the positive direction of an axis, their other fingers will curl in the positive direction of rotation
 
{{tip|Since many conflicting definitions are used in rotation, being explicit when it comes to naming can help avoid confusion}} }}
 
== Converting from Vector ==
 
As there is no specific [[Data Descriptions#DEFINE FIELD|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:
 
<source lang=cpp>
QAngle angMyAngle = QAngle(vecFromHammer.x, vecFromHammer.y, vecFromHammer.z);
 
// Conversion back to a vector, if required
AngleVectors(angMyAngle, &vecFromHammer);</source>
 
== Presence ==
 
* SP 2013 ([https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/sp/src/public/mathlib/vector.h#L1661 blob] [https://github.com/ValveSoftware/source-sdk-2013/blob/master/sp/src/public/mathlib/vector.h#L1661 master])
* MP 2013 ([https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/public/mathlib/vector.h#L1661 blob] [https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/public/mathlib/vector.h#L1661 master])
 
== See also ==
 
* [[Wikipedia:Yaw, pitch, and roll]]
* [[getpos]]
* [[Vector]] and [[Coordinates]]
* [[AngleVectors()|<code>AngleVectors()</code> / <code>VectorAngles()</code>]]
 
[[Category:Source class]]
[[Category:Glossary]]
[[Category:Variables]]

Latest revision as of 09:40, 12 July 2024

English (en)Deutsch (de)Русский (ru)中文 (zh)Translate (Translate)

QAngle is a C++ class in Source that represents a three-dimensional extrinsic Tait-Bryan rotations following the right-hand rule, offset from the cardinal Z axis. Each QAngle contains three vec t rotation values:

X

X pitch +down/-up

Y

Y yaw +left/-right

Z

Z roll +right/-left

(-45,10,0) means 45° up, 10° left and 0° roll.

Tip.pngTip:The axes are sometimes called rX, rY and rZ to distinguish them from vector axes.
Note.pngNote:Z is clamped to +/-50 for player viewangles.

Declaration

QAngle angMyAngle = QAngle(-45,10,0);
  • 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.

Orientation

To get a feeling for how a QAngle([X], [Y], [Z]) works, imagine a first-person perspective:

  • Looking down or up corresponds to positive or negative [X]
  • Looking left or right corresponds to positive or negative [Y]
  • Tilting your head so your right or left ear faces the ground corresponds to positive or negative [Z]

To relate this back to vectors and coordinates: The values of [X], [Y], and [Z] correspond to a clockwise rotation (in degrees) around the absolute axes[confirm] y, z, and x, respectively.

"Clockwise rotation" in an axis assumes the viewer is located at the origin looking in the positive direction of said axis.

Naming Conventions

Different fields use different naming conventions to describe these angles. To clear up any conflicting terms, short explanations are included below. Source Engine seems to draw its lingo from Aerospace Engineering.

Aerospace Engineering

When imagining a plane, pitch moves the nose up and down, yaw moves the nose left and right, and roll causes one wing to move up and the other wing to move down.

In Aerospace Engineering, this system is also referred to as Euler angles if — unlike QAngles — the axes rotate along. See "Mathematics" for clarification.

Mathematics

Strictly speaking, QAngles would be defined as extrinsic Tait-Bryan rotations following the right-hand rule. The terms "Tait-Bryan angles" and "Euler angles" are sometimes used interchangeably however. Breaking down this name into digestible chunks:
  • The difference between intrinsic and extrinsic rotations, is that with the former, each rotation shifts the axes along with it
  • The difference between proper Euler angles and Tait-Bryan angles, is that the former rotates twice around one axis and once around another (alternatingly), while the latter rotates once around all three axes
  • The right-hand rule states that if the thumb of one's right hand is pointing along the positive direction of an axis, their other fingers will curl in the positive direction of rotation
Tip.pngTip:Since many conflicting definitions are used in rotation, being explicit when it comes to naming can help avoid confusion

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);

Presence

See also