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

Difference between revisions of "makevectors"

From Quake Wiki

Line 1: Line 1:
====Syntax:====
+
''void'' '''makevectors'''(''vector'' angs)
<code>void makevectors(vector angles)</code>
 
  
Creates relative forward, right and up vectors with length 1 from angles. These 3 directional vectors are stored in the global variables <code>v_forward</code>, <code>v_right</code> and <code>v_up</code> respectively.
+
== Usage ==
Note that because these are global variables, running makevectors on another set of angles will destroy the previously calculated vectors.
+
Takes the passed angles and converts them into its three local axes i.e. its 3D rotation matrix. These axes are stored in the '''v_forward''', '''v_right''', and '''v_up''' globals. '''v_forward''' points in the direction of the angles, '''v_right''' points 90 degrees to the right of '''v_forward''', and '''v_up''' points 90 degrees above '''v_forward'''. This is useful if you need to offset relative to an angle e.g. in the direction an entity is facing.
====Parameters:====
+
 
:<code>angles</code> - The angles that will be used to generate the vectors
+
'''Warning:''' A bug exists with <code>vectoangles()</code> where the pitch is not negated correctly. If you pass the results of this function or the '''angles''' field of an entity, the pitch (the x value) must be negated first.
====Returns:====
+
 
:void
+
=== Parameters ===
 +
*''angs''
 +
:The angles that will be used to generate the axes as (pitch, yaw, roll).
 +
 
 +
== Example ==
 +
// Get the axes in the direction the player is looking
 +
makevectors(player.v_angle);
 +
 +
// Offset 1024 map units in the direction the player is looking
 +
traceline(player.origin, player.origin + v_forward*1024, 0, player);
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Revision as of 10:21, 31 July 2023

void makevectors(vector angs)

Usage

Takes the passed angles and converts them into its three local axes i.e. its 3D rotation matrix. These axes are stored in the v_forward, v_right, and v_up globals. v_forward points in the direction of the angles, v_right points 90 degrees to the right of v_forward, and v_up points 90 degrees above v_forward. This is useful if you need to offset relative to an angle e.g. in the direction an entity is facing.

Warning: A bug exists with vectoangles() where the pitch is not negated correctly. If you pass the results of this function or the angles field of an entity, the pitch (the x value) must be negated first.

Parameters

  • angs
The angles that will be used to generate the axes as (pitch, yaw, roll).

Example

// Get the axes in the direction the player is looking
makevectors(player.v_angle);

// Offset 1024 map units in the direction the player is looking
traceline(player.origin, player.origin + v_forward*1024, 0, player);