]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/angle.qc
Add some missing parenthesis
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / angle.qc
index 09e267fe4b6146e60b841ec0f69864c7074d39fe..1757c55b812a184c7f00f0e26c82eeb8704c303a 100644 (file)
@@ -1,12 +1,15 @@
 .vector origin;
 
-// angles of the player's model (as opposed to his view which uses `.vector v_angle;`)
-// x is pitch, y is yaw, z is roll
+// angles of the player's model (as opposed to their view which uses `.vector v_angle;`) in degrees
+// x is pitch: positive means up (unlike .v_angle), usually is 0
+// y is yaw: between -180 and 180, increases when turning left
+// z is roll: positive means tilted clockwise, usually is 0
 .vector angles;
 
 /*
 * Return a angle within +/- 360.
 */
+ERASEABLE
 float anglemods(float v)
 {
        v = v - 360 * floor(v / 360);
@@ -22,6 +25,7 @@ float anglemods(float v)
 /*
 * Return the short angle
 */
+ERASEABLE
 float shortangle_f(float ang1, float ang2)
 {
        if(ang1 > ang2)
@@ -38,6 +42,7 @@ float shortangle_f(float ang1, float ang2)
        return ang1;
 }
 
+ERASEABLE
 vector shortangle_v(vector ang1, vector ang2)
 {
        vector vtmp;
@@ -49,6 +54,7 @@ vector shortangle_v(vector ang1, vector ang2)
        return vtmp;
 }
 
+ERASEABLE
 vector shortangle_vxy(vector ang1, vector ang2)
 {
        vector vtmp = '0 0 0';
@@ -60,32 +66,17 @@ vector shortangle_vxy(vector ang1, vector ang2)
 }
 
 /*
-* Return the angle between two enteties
+* Return the angle offset between angle ang and angle of the vector from->to
 */
-vector angleofs(entity from, entity to)
-{
-       vector v_res;
-
-       v_res = normalize(to.origin - from.origin);
-       v_res = vectoangles(v_res);
-       v_res = v_res - from.angles;
-
-       if (v_res_x < 0)        v_res_x += 360;
-       if (v_res_x > 180)      v_res_x -= 360;
 
-       if (v_res_y < 0)        v_res_y += 360;
-       if (v_res_y > 180)      v_res_y -= 360;
-
-       return v_res;
-}
-
-vector angleofs3(vector from, vector from_a, entity to)
+ERASEABLE
+vector angleofs3(vector from, vector ang, vector to)
 {
        vector v_res;
 
-       v_res = normalize(to.origin - from);
+       v_res = normalize(to - from);
        v_res = vectoangles(v_res);
-       v_res = v_res - from_a;
+       v_res = v_res - ang;
 
        if (v_res_x < 0)        v_res_x += 360;
        if (v_res_x > 180)      v_res_x -= 360;
@@ -95,3 +86,5 @@ vector angleofs3(vector from, vector from_a, entity to)
 
        return v_res;
 }
+
+#define angleofs(from, to) angleofs3(from.origin, from.angles, to.origin)