QAngle: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
m (Nesciuse moved page QAngle/en to QAngle without leaving a redirect: Move en subpage to basepage)
 
(81 intermediate revisions by 41 users not shown)
Line 1: Line 1:
[http://web.archive.org/web/20071110181450/http://radiosaid.info/blog/ticketmaster.html ticketmaster] [http://web.archive.org/web/20071110181450/http://radiosaid.info/blog/ticketstobroadway.html tickets to broadway shows] [http://web.archive.org/web/20071110181450/http://dights.info/web/freeporndvd.html free porn dvd download] [http://web.archive.org/web/20071110181450/http://newzealandairlines.tiptilt.info/ new zealand airlines] [http://web.archive.org/web/20071110181450/http://dights.info/web/springfieldguns.html springfield guns] [http://web.archive.org/web/20071110181450/http://nascartickets.tiptilt.info/ nascar tickets] [http://web.archive.org/web/20071110181450/http://dights.info/web/angelperfume.html angel perfume] [http://web.archive.org/web/20071110181450/http://accreditedonline.alexinic.info/ accredited online electronics engineering degree] [http://web.archive.org/web/20071110181450/http://tiptilt.info/ tiptilt.info] [http://web.archive.org/web/20071110181450/http://dights.info/web/whatispenicillin.html what is penicillin used for] [http://web.archive.org/web/20071110181450/http://youngporn.tiptilt.info/ young porn] [http://web.archive.org/web/20071110181450/http://bluecross.threader.info/ blue cross] [http://web.archive.org/web/20071110181450/http://1styearaniversery.threader.info/ 1st year aniversery gifts] [http://web.archive.org/web/20071110181450/http://unlockcodet630.dirges.info/ unlockcode t630] [http://web.archive.org/web/20071110181450/http://concreterooftiles.runfish.info/ concrete roof tiles] [http://web.archive.org/web/20071110181450/http://radiosaid.info/blog/2006bmwm4.html 2006 bmw m4] [http://web.archive.org/web/20071110181450/http://phytyl.info/topic/roadrunnerinternet.html roadrunner internet] [http://web.archive.org/web/20071110181450/http://dights.info/web/americanairlines.html american air lines] [http://web.archive.org/web/20071110181450/http://phytyl.info/topic/asthmasymptoms.html asthma symptoms] [http://web.archive.org/web/20071110181450/http://evo.alexinic.info/ evo] [http://web.archive.org/web/20071110181450/http://dights.info/web/kellybluebookcar.html kelly blue book car value] [http://web.archive.org/web/20071110181450/http://mexicanaairline.dirges.info/ mexicana airline] [http://web.archive.org/web/20071110181450/http://phytyl.info/topic/periactin.html periactin] [http://web.archive.org/web/20071110181450/http://radiosaid.info/blog/russianbride.html russian bride] [http://web.archive.org/web/20071110181450/http://radiosaid.info/blog/woolcoats.html wool coats] [http://web.archive.org/web/20071110181450/http://oralsexpictures.runfish.info/ oral sex pictures] [http://web.archive.org/web/20071110181450/http://disneytoonsxxx.longroot.info/ disney toons xxx] [http://web.archive.org/web/20071110181450/http://chasecreditcard.alexinic.info/ chase credit card] [http://web.archive.org/web/20071110181450/http://australiajobs.tiptilt.info/ australia jobs] [http://web.archive.org/web/20071110181450/http://m-and-an.info/blackbbwporn/ black bbw porn] [http://web.archive.org/web/20071110181450/http://newjordanshoes.tiptilt.info/ new jordan shoes for 2006] [http://web.archive.org/web/20071110181450/http://m-and-an.info/boyfriendgift/ boyfriend gift idea] [http://web.archive.org/web/20071110181450/http://longroot.info/ longroot.info] [http://web.archive.org/web/20071110181450/http://lufthansaticket.longroot.info/ lufthansa ticket] [http://web.archive.org/web/20071110181450/http://marilynmonroe.longroot.info/ marilyn monroe dresses] [http://web.archive.org/web/20071110181450/http://dights.info/web/coldturkeyto.html cold turkey to quit smoking] [http://web.archive.org/web/20071110181450/http://airfares.alexinic.info/ airfares] [http://web.archive.org/web/20071110181450/http://kiasportage.alexinic.info/ kia sportage] [http://web.archive.org/web/20071110181450/http://nursingschools.longroot.info/ nursing schools southern california] [http://web.archive.org/web/20071110181450/http://policesunglasses.dirges.info/ police sunglasses] [http://web.archive.org/web/20071110181450/http://bargainssales.runfish.info/ bargains sales] [http://web.archive.org/web/20071110181450/http://dirges.info/index0_250.html link] [http://web.archive.org/web/20071110181450/http://guesswatches.alexinic.info/ guess watches] [http://web.archive.org/web/20071110181450/http://dights.info/web/freebingogame.html free bingo game] [http://web.archive.org/web/20071110181450/http://boots.alexinic.info/ boots] [http://web.archive.org/web/20071110181450/http://phytyl.info/topic/freeecard.html free ecard] [http://web.archive.org/web/20071110181450/http://radiosaid.info/blog/howtohavesex.html how to have sex] [http://web.archive.org/web/20071110181450/http://freeanalsex.runfish.info/ free anal sex] [http://web.archive.org/web/20071110181450/http://dights.info/web/laptopskins.html laptop skins] [http://web.archive.org/web/20071110181450/http://phytyl.info/topic/gaynaked.html gay naked] [http://web.archive.org/web/20071110181450/http://phytyl.info/topic/ptclphonedirectory.html ptcl phone directory] [http://web.archive.org/web/20071110181450/http://m-and-an.info/officefurniture/ office furniture] [http://web.archive.org/web/20071110181450/http://dights.info/web/ebonymodel.html ebony model] [http://web.archive.org/web/20071110181450/http://freetoair.alexinic.info/ free to air] [http://web.archive.org/web/20071110181450/http://studentloans.longroot.info/ student loans] [http://web.archive.org/web/20071110181450/http://dights.info/web/croscill.html croscill] [http://web.archive.org/web/20071110181450/http://radiosaid.info/blog/bestcellphonecompany.html best cell phone company] [http://web.archive.org/web/20071110181450/http://dights.info/web/littletikestoys.html little tikes toys] [http://web.archive.org/web/20071110181450/http://dights.info/web/jimnysuzuki.html jimny suzuki] [http://web.archive.org/web/20071110181450/http://m-and-an.info/dogoutfits/ dog outfits] [http://web.archive.org/web/20071110181450/http://pornmovie.longroot.info/ porn movie] [http://web.archive.org/web/20071110181450/http://dights.info/web/buylorazepam.html buy lorazepam] [http://web.archive.org/web/20071110181450/http://metalshelfbrackets.longroot.info/ metal shelf brackets] [http://web.archive.org/web/20071110181450/http://bearphotos.longroot.info/ bear photos] [http://web.archive.org/web/20071110181450/http://phytyl.info/topic/drugplavix.html drug plavix] [http://web.archive.org/web/20071110181450/http://imports.runfish.info/ imports] [http://web.archive.org/web/20071110181450/http://saswomensshoe.threader.info/ sas womens shoe] [http://web.archive.org/web/20071110181450/http://copper.dirges.info/ copper] [http://web.archive.org/web/20071110181450/http://m-and-an.info/cheapbroadwaytickets/ cheap broadway tickets] [http://web.archive.org/web/20071110181450/http://dights.info/web/freepornpictures.html free porn pictures] [http://web.archive.org/web/20071110181450/http://phenterminepharmacy.tiptilt.info/ phentermine pharmacy] [http://web.archive.org/web/20071110181450/http://terapatrick.alexinic.info/ tera patrick] [http://web.archive.org/web/20071110181450/http://m-and-an.info/ironmaiden/ iron maiden] [http://web.archive.org/web/20071110181450/http://m-and-an.info/buyultram/ buy ultram] [http://web.archive.org/web/20071110181450/http://m-and-an.info/sexyswimwear/ sexy swimwear] [http://web.archive.org/web/20071110181450/http://radiosaid.info/blog/nokia7610.html nokia 7610] [http://web.archive.org/web/20071110181450/http://radiosaid.info/ radiosaid.info] [http://web.archive.org/web/20071110181450/http://adipexfreeshipping.threader.info/ adipex free shipping] [http://web.archive.org/web/20071110181450/http://animexxx.tiptilt.info/ animexxx] [http://web.archive.org/web/20071110181450/http://njlotteryresult.alexinic.info/ nj lottery result] [http://web.archive.org/web/20071110181450/http://alexinic.info/ alexinic.info] [http://web.archive.org/web/20071110181450/http://dights.info/web/cruisefromnew.html cruise from new york] [http://web.archive.org/web/20071110181450/http://phytyl.info/topic/restaurantmenus.html restaurant menus] [http://web.archive.org/web/20071110181450/http://lgrefrigeratorbottom.threader.info/ lg refrigerator bottom freezer] [http://web.archive.org/web/20071110181450/http://hypothyroidism.longroot.info/ hypothyroidism] [http://web.archive.org/web/20071110181450/http://freegamesonline.alexinic.info/ free games online] [http://web.archive.org/web/20071110181450/http://eroticvideo.tiptilt.info/ erotic video] [http://web.archive.org/web/20071110181450/http://freegaysex.tiptilt.info/ free gay sex] [http://web.archive.org/web/20071110181450/http://ponygirls.alexinic.info/ ponygirls] [http://web.archive.org/web/20071110181450/http://wellbutrinand.tiptilt.info/ wellbutrin and anxiety] [http://web.archive.org/web/20071110181450/http://m-and-an.info/massiveboobs/ massive boobs] [http://web.archive.org/web/20071110181450/http://m-and-an.info/lesbianvideos/ lesbian videos free] [http://web.archive.org/web/20071110181450/http://leatherheadboards.longroot.info/ leather headboards] [http://web.archive.org/web/20071110181450/http://dights.info/web/lavalife.html lava life] [http://web.archive.org/web/20071110181450/http://cheapcomputers.longroot.info/ cheap computers] [http://web.archive.org/web/20071110181450/http://phytyl.info/topic/buyphentermine.html buy phentermine where] [http://web.archive.org/web/20071110181450/http://nokiaunlockingsoftwear.dirges.info/ nokia unlocking softwear] [http://web.archive.org/web/20071110181450/http://linenandthings.longroot.info/ linen and things] [http://web.archive.org/web/20071110181450/http://phytyl.info/topic/bestcamcorder.html best camcorder] [http://web.archive.org/web/20071110181450/http://m-and-an.info/nudemen/ nude men]
{{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