Xonotic
anglestransform.qc File Reference
#include "anglestransform.qh"
+ Include dependency graph for anglestransform.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

vector AnglesTransform_Apply (vector transform, vector v)
 
vector AnglesTransform_ApplyToAngles (vector transform, vector v)
 
vector AnglesTransform_ApplyToVAngles (vector transform, vector v)
 
vector AnglesTransform_CancelRoll (vector t)
 
vector AnglesTransform_FromAngles (vector v)
 
vector AnglesTransform_FromVAngles (vector v)
 
vector AnglesTransform_Invert (vector transform)
 
vector AnglesTransform_LeftDivide (vector from_transform, vector to_transform)
 
vector AnglesTransform_Multiply (vector t1, vector t2)
 
vector AnglesTransform_Multiply_GetPostShift (vector t0, vector st0, vector t1, vector st1)
 
vector AnglesTransform_Normalize (vector t, float minimize_roll)
 
vector AnglesTransform_PrePostShift_GetPostShift (vector sf, vector t, vector st)
 
vector AnglesTransform_RightDivide (vector to_transform, vector from_transform)
 
vector AnglesTransform_ToAngles (vector v)
 
vector AnglesTransform_ToVAngles (vector v)
 
vector AnglesTransform_TurnDirectionFR (vector transform)
 
vector AnglesTransform_TurnDirectionFU (vector transform)
 

Function Documentation

◆ AnglesTransform_Apply()

vector AnglesTransform_Apply ( vector  transform,
vector  v 
)

Definition at line 5 of file anglestransform.qc.

References FIXED_MAKE_VECTORS, and vector().

Referenced by AnglesTransform_Multiply(), AnglesTransform_Multiply_GetPostShift(), AnglesTransform_PrePostShift_GetPostShift(), Portal_ApplyTransformToPlayerAngle(), Portal_TeleportPlayer(), skel_set_boneabs(), WarpZone_TransformOrigin(), WarpZone_TransformVelocity(), WarpZone_UnTransformOrigin(), and WarpZone_UnTransformVelocity().

6 {
7  vector forward, right, up;
8  FIXED_MAKE_VECTORS(transform, forward, right, up);
9  return forward * v.x + right * (-v.y) + up * v.z;
10 }
#define FIXED_MAKE_VECTORS
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_ApplyToAngles()

vector AnglesTransform_ApplyToAngles ( vector  transform,
vector  v 
)

Definition at line 129 of file anglestransform.qc.

References AnglesTransform_Multiply(), and v.

Referenced by AnglesTransform_ToVAngles(), CheatCommand(), Portal_TeleportPlayer(), WarpZone_TransformAngles(), and WarpZone_UnTransformAngles().

130 {
131  v.x = -v.x;
132  v = AnglesTransform_Multiply(transform, v);
133  v.x = -v.x;
134  return v;
135 }
vector AnglesTransform_Multiply(vector t1, vector t2)
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_ApplyToVAngles()

vector AnglesTransform_ApplyToVAngles ( vector  transform,
vector  v 
)

Definition at line 136 of file anglestransform.qc.

References AnglesTransform_Multiply(), and v.

Referenced by AnglesTransform_ToVAngles(), WarpZone_TransformVAngles(), and WarpZone_UnTransformVAngles().

137 {
138  v = AnglesTransform_Multiply(transform, v);
139  return v;
140 }
vector AnglesTransform_Multiply(vector t1, vector t2)
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_CancelRoll()

vector AnglesTransform_CancelRoll ( vector  t)

Definition at line 96 of file anglestransform.qc.

References fabs().

Referenced by WarpZone_TransformVAngles(), and WarpZone_UnTransformVAngles().

97 {
98  const float epsilon = 30;
99  float f;
100 
101  // constraints:
102  // forward vector (NOT SO important)
103  // right vector, up vector: screen rotation (MORE important)
104  // choose best match among all pitch-yaw only rotations
105 
106  // FIXME find a better method
107 
108  f = fabs(t.x - (-90)) / epsilon;
109  if(f < 1)
110  {
111  //t_x = -90;
112  t.y += t.z;
113  t.z = 0;
114  }
115  else
116  {
117  f = fabs(t.x - 90) / epsilon;
118  if(f < 1)
119  {
120  //t_x = 90;
121  t.y -= t.z;
122  t.z = 0;
123  }
124  }
125  return t;
126 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_FromAngles()

vector AnglesTransform_FromAngles ( vector  v)

Definition at line 141 of file anglestransform.qc.

References v.

Referenced by AnglesTransform_ToVAngles(), FindConnectedComponent(), Projectile_Draw(), and vehicle_aimturret().

142 {
143  v.x = -v.x;
144  return v;
145 }
vector v
Definition: ent_cs.qc:116
+ Here is the caller graph for this function:

◆ AnglesTransform_FromVAngles()

vector AnglesTransform_FromVAngles ( vector  v)

Definition at line 151 of file anglestransform.qc.

References v.

Referenced by AnglesTransform_ToVAngles(), and FindConnectedComponent().

152 {
153  return v;
154 }
vector v
Definition: ent_cs.qc:116
+ Here is the caller graph for this function:

◆ AnglesTransform_Invert()

vector AnglesTransform_Invert ( vector  transform)

Definition at line 21 of file anglestransform.qc.

References FIXED_MAKE_VECTORS, fixedvectoangles2, and vector().

Referenced by AnglesTransform_LeftDivide(), AnglesTransform_RightDivide(), skel_set_boneabs(), WarpZone_Accumulator_AddInverseTransform(), WarpZone_UnTransformAngles(), WarpZone_UnTransformOrigin(), WarpZone_UnTransformVAngles(), and WarpZone_UnTransformVelocity().

22 {
23  vector i_forward, i_up;
24  vector forward, right, up;
25  FIXED_MAKE_VECTORS(transform, forward, right, up);
26  // we want angles that turn forward into '1 0 0', right into '0 1 0' and up into '0 0 1'
27  // but these are orthogonal unit vectors!
28  // so to invert, we can simply fixedvectoangles the TRANSPOSED matrix
29  // TODO is this always -transform?
30  i_forward.x = forward.x;
31  i_forward.y = -right.x;
32  i_forward.z = up.x;
33  i_up.x = forward.z;
34  i_up.y = -right.z;
35  i_up.z = up.z;
36  return fixedvectoangles2(i_forward, i_up);
37 }
#define FIXED_MAKE_VECTORS
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define fixedvectoangles2(a, b)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_LeftDivide()

vector AnglesTransform_LeftDivide ( vector  from_transform,
vector  to_transform 
)

Definition at line 71 of file anglestransform.qc.

References AnglesTransform_Invert(), and AnglesTransform_Multiply().

Referenced by skel_set_boneabs(), and vehicle_aimturret().

72 {
73  return AnglesTransform_Multiply(AnglesTransform_Invert(from_transform), to_transform);
74 }
vector AnglesTransform_Multiply(vector t1, vector t2)
vector AnglesTransform_Invert(vector transform)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_Multiply()

vector AnglesTransform_Multiply ( vector  t1,
vector  t2 
)

Definition at line 12 of file anglestransform.qc.

References AnglesTransform_Apply(), FIXED_MAKE_VECTORS, fixedvectoangles2, and vector().

Referenced by AnglesTransform_ApplyToAngles(), AnglesTransform_ApplyToVAngles(), AnglesTransform_LeftDivide(), AnglesTransform_RightDivide(), AnglesTransform_ToVAngles(), Projectile_Draw(), skeleton_from_frames(), WarpZone_Accumulator_AddTransform(), and WarpZone_FindRadius_Recurse().

13 {
14  vector forward, right, up;
15  FIXED_MAKE_VECTORS(t2, forward, right, up);
16  forward = AnglesTransform_Apply(t1, forward);
17  up = AnglesTransform_Apply(t1, up);
18  return fixedvectoangles2(forward, up);
19 }
#define FIXED_MAKE_VECTORS
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector AnglesTransform_Apply(vector transform, vector v)
#define fixedvectoangles2(a, b)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_Multiply_GetPostShift()

vector AnglesTransform_Multiply_GetPostShift ( vector  t0,
vector  st0,
vector  t1,
vector  st1 
)

Definition at line 192 of file anglestransform.qc.

References AnglesTransform_Apply().

Referenced by WarpZone_Accumulator_AddTransform(), and WarpZone_FindRadius_Recurse().

193 {
194  // we want the result of:
195  // t0 * (t1 * p + st1) + st0
196  // t0 * t1 * p + t0 * st1 + st0
197  return st0 + AnglesTransform_Apply(t0, st1);
198 }
vector AnglesTransform_Apply(vector transform, vector v)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_Normalize()

vector AnglesTransform_Normalize ( vector  t,
float  minimize_roll 
)

Definition at line 76 of file anglestransform.qc.

References rint().

Referenced by vehicle_aimturret(), WarpZone_TransformVAngles(), and WarpZone_UnTransformVAngles().

77 {
78  float need_flip;
79  // first, bring all angles in their range...
80  t.x = t.x - 360 * rint(t.x / 360);
81  t.y = t.y - 360 * rint(t.y / 360);
82  t.z = t.z - 360 * rint(t.z / 360);
83  if(minimize_roll)
84  need_flip = (t.z > 90 || t.z <= -90);
85  else
86  need_flip = (t.x > 90 || t.x < -90); // for pitch we prefer to allow exactly -90 degrees for looking straight down
87  if(need_flip)
88  {
89  if(t.x >= 0) t.x = 180 - t.x; else t.x = -180 - t.x;
90  if(t.y > 0) t.y -= 180; else t.y += 180;
91  if(t.z > 0) t.z -= 180; else t.z += 180;
92  }
93  return t;
94 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_PrePostShift_GetPostShift()

vector AnglesTransform_PrePostShift_GetPostShift ( vector  sf,
vector  t,
vector  st 
)

Definition at line 199 of file anglestransform.qc.

References AnglesTransform_Apply().

Referenced by WarpZone_Accumulator_AddInverseTransform(), and WarpZone_SetUp().

200 {
201  return st - AnglesTransform_Apply(t, sf);
202 }
vector AnglesTransform_Apply(vector transform, vector v)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_RightDivide()

vector AnglesTransform_RightDivide ( vector  to_transform,
vector  from_transform 
)

Definition at line 66 of file anglestransform.qc.

References AnglesTransform_Invert(), and AnglesTransform_Multiply().

Referenced by Portal_Connect(), and WarpZone_SetUp().

67 {
68  return AnglesTransform_Multiply(to_transform, AnglesTransform_Invert(from_transform));
69 }
vector AnglesTransform_Multiply(vector t1, vector t2)
vector AnglesTransform_Invert(vector transform)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_ToAngles()

vector AnglesTransform_ToAngles ( vector  v)

Definition at line 146 of file anglestransform.qc.

References v.

Referenced by AnglesTransform_ToVAngles(), FindConnectedComponent(), Projectile_Draw(), and vehicle_aimturret().

147 {
148  v.x = -v.x;
149  return v;
150 }
vector v
Definition: ent_cs.qc:116
+ Here is the caller graph for this function:

◆ AnglesTransform_ToVAngles()

vector AnglesTransform_ToVAngles ( vector  v)

Definition at line 155 of file anglestransform.qc.

References AnglesTransform_ApplyToAngles(), AnglesTransform_ApplyToVAngles(), AnglesTransform_FromAngles(), AnglesTransform_FromVAngles(), AnglesTransform_Multiply(), AnglesTransform_ToAngles(), AnglesTransform_ToVAngles(), v, and vector().

Referenced by AnglesTransform_ToVAngles(), and FindConnectedComponent().

156 {
157  return v;
158 }
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnglesTransform_TurnDirectionFR()

vector AnglesTransform_TurnDirectionFR ( vector  transform)

Definition at line 39 of file anglestransform.qc.

Referenced by Portal_Connect(), and WarpZone_SetUp().

40 {
41  // turn 180 degrees around v_up
42  // changes in-direction to out-direction
43  //fixedmakevectors(transform);
44  //return fixedvectoangles2(-1 * v_forward, 1 * v_up);
45  transform.x = -transform.x;
46  transform.y = 180 + transform.y;
47  transform.z = -transform.z;
48  // pitch: -s +c
49  // yaw: -s -c
50  // roll: -s +c
51  return transform;
52 }
+ Here is the caller graph for this function:

◆ AnglesTransform_TurnDirectionFU()

vector AnglesTransform_TurnDirectionFU ( vector  transform)

Definition at line 54 of file anglestransform.qc.

55 {
56  // turn 180 degrees around v_up
57  // changes in-direction to out-direction
58  //fixedmakevectors(transform);
59  //return fixedvectoangles2(-1 * v_forward, 1 * v_up);
60  transform.x = -transform.x;
61  transform.y = 180 + transform.y;
62  transform.z = 180 - transform.z;
63  return transform;
64 }