Xonotic
angle.qc
Go to the documentation of this file.
1 .vector origin;
2 
3 // angles of the player's model (as opposed to their view which uses `.vector v_angle;`) in degrees
4 // x is pitch: positive means up (unlike .v_angle), usually is 0
5 // y is yaw: between -180 and 180, increases when turning left
6 // z is roll: positive means tilted clockwise, usually is 0
7 .vector angles;
8 
9 /*
10 * Return a angle within +/- 360.
11 */
13 float anglemods(float v)
14 {
15  v = v - 360 * floor(v / 360);
16 
17  if(v >= 180)
18  return v - 360;
19  else if(v <= -180)
20  return v + 360;
21  else
22  return v;
23 }
24 
25 /*
26 * Return the short angle
27 */
29 float shortangle_f(float ang1, float ang2)
30 {
31  if(ang1 > ang2)
32  {
33  if(ang1 > 180)
34  return ang1 - 360;
35  }
36  else
37  {
38  if(ang1 < -180)
39  return ang1 + 360;
40  }
41 
42  return ang1;
43 }
44 
47 {
48  vector vtmp;
49 
50  vtmp_x = shortangle_f(ang1_x,ang2_x);
51  vtmp_y = shortangle_f(ang1_y,ang2_y);
52  vtmp_z = shortangle_f(ang1_z,ang2_z);
53 
54  return vtmp;
55 }
56 
59 {
60  vector vtmp = '0 0 0';
61 
62  vtmp_x = shortangle_f(ang1_x,ang2_x);
63  vtmp_y = shortangle_f(ang1_y,ang2_y);
64 
65  return vtmp;
66 }
67 
68 /*
69 * Return the angle offset between angle ang and angle of the vector from->to
70 */
71 
74 {
75  vector v_res;
76 
77  v_res = normalize(to - from);
78  v_res = vectoangles(v_res);
79  v_res = v_res - ang;
80 
81  if (v_res_x < 0) v_res_x += 360;
82  if (v_res_x > 180) v_res_x -= 360;
83 
84  if (v_res_y < 0) v_res_y += 360;
85  if (v_res_y > 180) v_res_y -= 360;
86 
87  return v_res;
88 }
89 
90 #define angleofs(from, to) angleofs3(from.origin, from.angles, to.origin)
ERASEABLE vector shortangle_v(vector ang1, vector ang2)
Definition: angle.qc:46
ERASEABLE float anglemods(float v)
Definition: angle.qc:13
ERASEABLE vector angleofs3(vector from, vector ang, vector to)
Definition: angle.qc:73
entity to
Definition: self.qh:96
#define ERASEABLE
Definition: _all.inc:35
ERASEABLE float shortangle_f(float ang1, float ang2)
Definition: angle.qc:29
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector v
Definition: ent_cs.qc:116
ERASEABLE vector shortangle_vxy(vector ang1, vector ang2)
Definition: angle.qc:58
vector origin
Definition: angle.qc:1
vector angles
Definition: angle.qc:7