Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Difference between revisions of "vectoangles"

From Quake Wiki

m (Return)
 
Line 9: Line 9:
  
 
=== Return ===
 
=== Return ===
The yaw and pitch in a vector as (pitch, yaw, 0).
+
The yaw and pitch in a vector as (pitch, yaw, 0). Values range from [0, 360).
  
 
'''Warning:''' Due to an oversight, the pitch value this function returns is negated. This works fine if setting it to '''angles''', but if you're using it with <code>makevectors()</code> be sure to negate the pitch (the x value) first.
 
'''Warning:''' Due to an oversight, the pitch value this function returns is negated. This works fine if setting it to '''angles''', but if you're using it with <code>makevectors()</code> be sure to negate the pitch (the x value) first.

Latest revision as of 14:05, 10 August 2023

vector vectoangles(vector vec)

Usage[edit]

Calculates the yaw and pitch of the passed vector. Useful for converting a direction back into angles e.g. a missile's velocity.

Parameters[edit]

  • vec
The vector to get the angles from.

Return[edit]

The yaw and pitch in a vector as (pitch, yaw, 0). Values range from [0, 360).

Warning: Due to an oversight, the pitch value this function returns is negated. This works fine if setting it to angles, but if you're using it with makevectors() be sure to negate the pitch (the x value) first.

Example[edit]

// After a missile calculates its velocity, set its angles to match
missile.velocity = dir * 1024;
missile.angles = vectoangles(missile.velocity);