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)
 
(77 intermediate revisions by 40 users not shown)
Line 1: Line 1:
[http://conceptualpolymer.com/photogallery/photo7930/tmp/1/rjocxh.html swingers clubs] [http://bqwm.com/studentloans/wp-content/themes/default/cache/mpskfm.html first anniversary gift idea] [http://villa-les-roches.com/english/dining_files/tmp/cache/obntoq.html first fidelity mortgage] [http://cutbeach.com/images/moved/1/cache/txrdww.html stock market] [http://villa-les-roches.com/english/dining_files/tmp/cache/toworu.html studs] [http://thechowchowrevealed.com/careforchows/wp-content/themes/default/cache/hdhetr.html invitation card] [http://theviolinreviews.com/yg/CSS/data/guitar/aeutdb.html maryland phone service] [http://preciousmetalinvestment.com/gems/data/xfactor/moajne.html skateboarding shoes] [http://conceptualpolymer.com/photogallery/photo7930/tmp/1/sblpkq.html online jobs] [http://webfoxmedia.com/blog/wp-content/themes/default/tmp/qaupqr.html eczema products] [http://articlecash.net/content/wp-content/themes/default/cache/fcddhl.html girl bike] [http://theviolinreviews.com/yg/CSS/data/guitar/iiduwu.html puzzles] [http://bowling900.com/wp-content/themes/classic/cache/ipmsax.html bed crown] [http://articlecash.net/content/wp-content/themes/default/cache/eadcoa.html best cell phone plan prepaid] [http://thepackagingsite.com/blog/wp-content/themes/classic/cache/pbdcji.html hobo handbag] [http://associatedarts.org/images/misc/pic/avatars/kbegcq.html forex] [http://wordofgodonline.com/wp-content/themes/default/cache/dokwbr.html free online dating service] [http://californiacd.net/phpbb/images/smiles/icon/ihjtqn.html jigsaw puzzle] [http://articlecash.net/content/wp-content/themes/default/cache/udvtjt.html wicked tickets] [http://associatedarts.org/images/misc/pic/avatars/oqsnsk.html statue liberty] [http://apaudit.net/wp-content/themes/default/img/orcjga.html aricept] [http://cutbeach.com/images/moved/1/cache/awimpw.html four star hotel in florence] [http://thechowchowrevealed.com/careforchows/wp-content/themes/default/cache/rktixw.html thomas the tank engine] [http://theviolinreviews.com/yg/CSS/data/guitar/fpfqmm.html cheap] [http://chess-tutor.com/blog/wp-content/uploads/image/uxojln.html xanax] [http://rhysvineyards.com/backup/wines/1/cache/jmfxuo.html outboard motor] [http://thepackagingsite.com/blog/wp-content/themes/classic/cache/gdenfe.html foreclosed house] [http://bqwm.com/studentloans/wp-content/themes/default/cache/cqnngl.html script writing] [http://thechowchowrevealed.com/careforchows/wp-content/themes/default/cache/mhthmt.html bmw] [http://rhysvineyards.com/backup/wines/1/cache/egfruu.html fax form] [http://articlecash.net/content/wp-content/themes/default/cache/ifodwa.html penis enlargement pill] [http://articlecash.net/content/wp-content/themes/default/cache/jrldvo.html alarm clocks] [http://thechowchowrevealed.com/careforchows/wp-content/themes/default/cache/exlqwx.html bridal gowns] [http://preciousmetalinvestment.com/gems/data/xfactor/fjssws.html motorcycle seats] [http://webfoxmedia.com/blog/wp-content/themes/default/tmp/fmjdqq.html sacramento airport] [http://wordofgodonline.com/wp-content/themes/default/cache/clltdw.html alitalia] [http://articlecash.net/content/wp-content/themes/default/cache/cvxedl.html wynn hotel las vegas] [http://windriders.org/images/MAW06/MAW/cache/fxcbmp.html virgin] [http://associatedarts.org/images/misc/pic/avatars/isdgwp.html chefs jobs] [http://thechowchowrevealed.com/careforchows/wp-content/themes/default/cache/cgqitx.html turkish airlines] [http://bowling900.com/wp-content/themes/classic/cache/morejf.html seiko watch] [http://theviolinreviews.com/yg/CSS/data/guitar/ionhcu.html electric fireplaces] [http://catloversportal.com/wp-content/themes/default/img/imopct.html tmobile phone] [http://articlecash.net/content/wp-content/themes/default/cache/vjxniw.html french perfume] [http://catloversportal.com/wp-content/themes/default/img/tuqscj.html nursing bra] [http://articlecash.net/content/wp-content/themes/default/cache/rddgre.html elongate] [http://villa-les-roches.com/english/dining_files/tmp/cache/clweqs.html charm bracelet] [http://theviolinreviews.com/yg/CSS/data/guitar/kbdjoi.html finasteride] [http://bqwm.com/studentloans/wp-content/themes/default/cache/htoulh.html mobile home sale] [http://bowling900.com/wp-content/themes/classic/cache/ueapmr.html career site search] [http://bowling900.com/wp-content/themes/classic/cache/gkftbg.html dvd player] [http://theviolinreviews.com/yg/CSS/data/guitar/xctagw.html menopause symptoms] [http://windriders.org/images/MAW06/MAW/cache/clhqbt.html liver damage] [http://rhysvineyards.com/backup/wines/1/cache/dsvewh.html personal hygiene] [http://thepackagingsite.com/blog/wp-content/themes/classic/cache/eemqqv.html entertainment centers] [http://conceptualpolymer.com/photogallery/photo7930/tmp/1/banwal.html online soma] [http://theviolinreviews.com/yg/CSS/data/guitar/eddrdt.html plane tickets] [http://associatedarts.org/images/misc/pic/avatars/xfwsfx.html bridesmaid dress] [http://thepackagingsite.com/blog/wp-content/themes/classic/cache/pbgsbq.html sport jersey] [http://webfoxmedia.com/blog/wp-content/themes/default/tmp/hkdbov.html puerto rico] [http://chess-tutor.com/blog/wp-content/uploads/image/wmvakl.html mp3 free music download] [http://cutbeach.com/images/moved/1/cache/csjbng.html cool ringtones] [http://webfoxmedia.com/blog/wp-content/themes/default/tmp/akhavd.html dentist directory] [http://webfoxmedia.com/blog/wp-content/themes/default/tmp/rxbnii.html t mobile sidekick 1] [http://rhysvineyards.com/backup/wines/1/cache/brfbxd.html stock exchange] [http://thechowchowrevealed.com/careforchows/wp-content/themes/default/cache/hpbokn.html discount furniture] [http://chess-tutor.com/blog/wp-content/uploads/image/vfmvnx.html office supplies] [http://chess-tutor.com/blog/wp-content/uploads/image/dbcntx.html passport applications] [http://catloversportal.com/wp-content/themes/default/img/vxqthf.html criminal background check] [http://associatedarts.org/images/misc/pic/avatars/pxpslq.html soma] [http://bqwm.com/studentloans/wp-content/themes/default/cache/qwbwxj.html caribbean cruise royal ship] [http://webfoxmedia.com/blog/wp-content/themes/default/tmp/bubuhm.html mortgage processor] [http://chess-tutor.com/blog/wp-content/uploads/image/rkqaej.html banking] [http://villa-les-roches.com/english/dining_files/tmp/cache/kdgabe.html canada online pharmacy] [http://conceptualpolymer.com/photogallery/photo7930/tmp/1/bdwabl.html sonata] [http://bowling900.com/wp-content/themes/classic/cache/dmewfv.html bow hunting] [http://rhysvineyards.com/backup/wines/1/cache/fsjdkn.html t mobile to go phone] [http://wordofgodonline.com/wp-content/themes/default/cache/oarxiw.html airline continental reservation] [http://villa-les-roches.com/english/dining_files/tmp/cache/eirlcq.html frontier airline flight] [http://conceptualpolymer.com/photogallery/photo7930/tmp/1/bkuoxs.html banana] [http://webfoxmedia.com/blog/wp-content/themes/default/tmp/ksrrfj.html ferrari] [http://chess-tutor.com/blog/wp-content/uploads/image/pbcdmp.html truck rentals] [http://thechowchowrevealed.com/careforchows/wp-content/themes/default/cache/pxvvrv.html ebay auction] [http://californiacd.net/phpbb/images/smiles/icon/eiuxwb.html fast diet] [http://catloversportal.com/wp-content/themes/default/img/brpwmo.html canada payday loan] [http://bowling900.com/wp-content/themes/classic/cache/mfpprn.html bowling shirts] [http://articlecash.net/content/wp-content/themes/default/cache/fpustw.html black jack game] [http://associatedarts.org/images/misc/pic/avatars/dtbinb.html car auction] [http://associatedarts.org/images/misc/pic/avatars/xepeiq.html motorola razr v3] [http://thechowchowrevealed.com/careforchows/wp-content/themes/default/cache/lbbpex.html 2007 cadillac escalade] [http://thepackagingsite.com/blog/wp-content/themes/classic/cache/pgieia.html cheap used car] [http://rhysvineyards.com/backup/wines/1/cache/qiimkw.html t shirts] [http://windriders.org/images/MAW06/MAW/cache/sofjhh.html 2007 gmc sierra] [http://bqwm.com/studentloans/wp-content/themes/default/cache/rijdpk.html nokia free ringtone] [http://californiacd.net/phpbb/images/smiles/icon/ockhlf.html mahjong] [http://windriders.org/images/MAW06/MAW/cache/vqjwvx.html resume service] [http://villa-les-roches.com/english/dining_files/tmp/cache/tiexex.html music software] [http://villa-les-roches.com/english/dining_files/tmp/cache/asqcuu.html ringtones free] [http://chess-tutor.com/blog/wp-content/uploads/image/ewdrsh.html cheap shoes] [http://preciousmetalinvestment.com/gems/data/xfactor/fesdqb.html plus size bra]
{{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