Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!
Difference between revisions of "vectoyaw"
From Quake Wiki
(Created page with "====Syntax:==== <code>float vectoyaw(vector vec)</code> Converts a directional vector into a yaw angle (only the _y component of an angles set) ====Parameters:==== :<code>vec...") |
m (→Example) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | ''float'' '''vectoyaw'''(''vector'' vec) | |
− | |||
− | + | == Usage == | |
− | + | Gets the arc tangent of the vector's x and y values. This is equivalent to <code>atan2</code> in other programming languages. | |
− | |||
− | |||
− | |||
+ | === Parameters === | ||
+ | *''vec'' | ||
+ | :Stores the x and y arguments to pass to <code>atan2</code>. The z value does nothing. | ||
+ | |||
+ | === Return === | ||
+ | The angle of the x and y components of the vector. Can be a value in the range [0, 360). | ||
+ | |||
+ | == Example == | ||
+ | // Checks to see if the monster's enemy is in front of them before attacking | ||
+ | float yawTo = vectoyaw(self.enemy.origin - self.origin); | ||
+ | |||
+ | float delta = anglemod(self.angles.y - yawTo); | ||
+ | if (delta > 45 && delta < 315) | ||
+ | return; | ||
[[Category:QuakeC Function]] | [[Category:QuakeC Function]] |
Latest revision as of 12:25, 31 July 2023
float vectoyaw(vector vec)
Contents
Usage[edit]
Gets the arc tangent of the vector's x and y values. This is equivalent to atan2
in other programming languages.
Parameters[edit]
- vec
- Stores the x and y arguments to pass to
atan2
. The z value does nothing.
Return[edit]
The angle of the x and y components of the vector. Can be a value in the range [0, 360).
Example[edit]
// Checks to see if the monster's enemy is in front of them before attacking float yawTo = vectoyaw(self.enemy.origin - self.origin); float delta = anglemod(self.angles.y - yawTo); if (delta > 45 && delta < 315) return;