Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
angle.qc
Go to the documentation of this file.
1.vector origin;
2
3.vector angles;
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
10float anglemods(float v)
11{
12 v -= 360 * floor(v / 360);
13
14 if (v >= 180)
15 return v - 360;
16 else if (v <= -180)
17 return v + 360;
18 return v;
19}
20
23float shortangle_f(float ang1, float ang2)
24{
25 if (ang1 > ang2)
26 {
27 if (ang1 > 180)
28 return ang1 - 360;
29 }
30 else
31 {
32 if (ang1 < -180)
33 return ang1 + 360;
34 }
35 return ang1;
36}
37
40{
41 vector vtmp;
42 vtmp.x = shortangle_f(ang1.x, ang2.x);
43 vtmp.y = shortangle_f(ang1.y, ang2.y);
44 vtmp.z = shortangle_f(ang1.z, ang2.z);
45 return vtmp;
46}
47
50{
51 vector vtmp;
52 vtmp.x = shortangle_f(ang1.x, ang2.x);
53 vtmp.y = shortangle_f(ang1.y, ang2.y);
54 vtmp.z = 0;
55 return vtmp;
56}
57
61{
62 vector v_res = normalize(to - from);
63 v_res = vectoangles(v_res) - ang;
64
65 if (v_res.x < 0) v_res.x += 360;
66 if (v_res.x > 180) v_res.x -= 360;
67
68 if (v_res.y < 0) v_res.y += 360;
69 if (v_res.y > 180) v_res.y -= 360;
70
71 return v_res;
72}
73
74#define angleofs(from, to) angleofs3(from.origin, from.angles, to.origin)
ERASEABLE vector shortangle_v(vector ang1, vector ang2)
Definition angle.qc:39
ERASEABLE float anglemods(float v)
Return a angle within +/- 360.
Definition angle.qc:10
ERASEABLE vector angleofs3(vector from, vector ang, vector to)
Return the angle offset between angle ang and angle of the vector from->to.
Definition angle.qc:60
ERASEABLE float shortangle_f(float ang1, float ang2)
Return the short angle.
Definition angle.qc:23
ERASEABLE vector shortangle_vxy(vector ang1, vector ang2)
Definition angle.qc:49
vector origin
ent angles
Definition ent_cs.qc:146
#define ERASEABLE
Definition _all.inc:37
vector vectoangles(vector v)
vector normalize(vector v)
float floor(float f)
vector
Definition self.qh:96
vector vector ang
Definition self.qh:96