QAngle: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(Undo revision 264965 by Soundwave (talk) This is the English page)
Tag: Undo
Line 2: Line 2:
{{toc-right}}
{{toc-right}}


'''QAngle''' это класс C++, который представляет трехмерный угол Эйлера, смещенный от кардинальной [[Coordinates|Z axis]]. Каждый QAngle содержит три значения поворота [[vec_t]]:
'''QAngle''' is a C++ class that represents a three-dimensional Euler angle, offset from the cardinal [[Coordinates|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


<code>(-45,10,0)</code> означает 45&deg; вверх, 10&deg; влево and 0&deg; поворота.
<code>(-45,10,0)</code> means 45&deg; up, 10&deg; left and 0&deg; roll.


{{Tip|Иногда называют rX, rY и rZ чтобы отделять их от углов [[vector]] .}}
{{tip|The axes are sometimes called rX, rY and rZ to distinguish them from [[vector]] axes.}}


{{Note|Z фиксируются +/-50 для игрока viewangles.}}
{{note|Z is clamped to +/-50 for player viewangles.}}


== Объявление ==
== Declaration ==


  QAngle angMyAngle = QAngle(-45,10,0);
  QAngle angMyAngle = QAngle(-45,10,0);


* Вы также можете назначить переменные-члены X, Y и Z отдельно.
* You could also assign to the X, Y and Z member variables separately.
* Префикс <code>ang</code> (иногда <code>a</code>) определяет переменную как угол.
* The prefix <code>ang</code> (or sometimes just <code>a</code>) identifies the variable as an angle.


== Направление ==
== Orientation ==


Как ни странно, ни одна из осей вращения источника не совпадает с их [[Coordinates|position axes]] сверстниками.
Confusingly, none of Source's rotation axes align with their [[Coordinates|position axes]] counterparts.


Еще более "запутанно", что Хаммер перечисляет оси вращения как Y, Z, X! Это совершенно неправильно, но, к счастью, это всего лишь метки: значения хранятся в одной строке (например, "-45 10 0") и интерпретируются игрой как
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 by the game as rX rY rZ.
rX rY rZ.


Помните, что эффективное направление угла определяется его системой отсчета. Как правило, он будет либо привязан к миру, либо к сущности.
Remember that the effective direction of an angle is determined by its frame of reference. Typically, it will either be aligned to the world or to an entity.


== Преобразование из векторов ==
== Converting from Vector ==


Поскольку нет никаких конкретных [[Data Descriptions#DEFINE_FIELD|datadesc keyfield]] для углов, один, выбранный в Hammer, прибудет как [[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>
<source lang=cpp>
Line 40: Line 39:
AngleVectors(angMyAngle, &vecFromHammer);</source>
AngleVectors(angMyAngle, &vecFromHammer);</source>


== Также посмотрите ==
== See Also ==


* [[Wikipedia:Yaw, pitch, and roll]]
* [[Wikipedia:Yaw, pitch, and roll]]

Revision as of 03:38, 25 September 2022

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

QAngle is a C++ class that represents a three-dimensional Euler angle, offset from the cardinal 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.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

Confusingly, none of Source's rotation axes align with their position axes counterparts.

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 by the game as rX rY rZ.

Remember that the effective direction of an angle is determined by its frame of reference. Typically, it will either be aligned to the world or to an entity.

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

See Also