#ifndef VECTOR_H
#define VECTOR_H
+noref vector _vlen2;
+#define vlen2(v) \
+ (_vlen2 = (v), \
+ _vlen2.x * _vlen2.x \
+ + _vlen2.y * _vlen2.y \
+ + _vlen2.z * _vlen2.z)
+
+noref float _vdist_f;
+/** Vector distance comparison, avoids sqrt() */
+#define vdist(v, cmp, f) (vlen2(v) cmp (_vdist_f = (f), _vdist_f * _vdist_f))
+/*
+#define vdist(v, cmp, f) (vlen(v) cmp (f))
+*/
+
+#define cross(a, b) ((a) >< (b))
+/*
+vector cross(vector a, vector b)
+{
+ return
+ '1 0 0' * (a.y * b.z - a.z * b.y)
+ + '0 1 0' * (a.z * b.x - a.x * b.z)
+ + '0 0 1' * (a.x * b.y - a.y * b.x);
+}
+*/
+
const vector eX = '1 0 0';
const vector eY = '0 1 0';
const vector eZ = '0 0 1';
return v;
}
-float vlen2d(vector v)
-{
- return sqrt(v.x * v.x + v.y * v.y);
-}
-
float vlen_maxnorm2d(vector v)
{
return max(v.x, v.y, -v.x, -v.y);
up = v_up; \
} while (0)
-vector vec2(vector v)
-{
- v.z = 0;
- return v;
-}
+noref vector _vec2;
+#define vec2(v) (_vec2 = (v), _vec2.z = 0, _vec2)
-vector vec3(float x, float y, float z)
-{
- vector v;
- v.x = x;
- v.y = y;
- v.z = z;
- return v;
-}
+noref vector _vec3;
+#define vec3(x, y, z) (_vec3_x = (x), _vec3_y = (y), _vec3_z = (z), _vec3)
vector rotate(vector v, float a)
{
return r;
}
-vector yinvert(vector v)
-{
- v.y = 1 - v.y;
- return v;
-}
+noref vector _yinvert;
+#define yinvert(v) (_yinvert = (v), _yinvert.y = 1 - _yinvert.y, _yinvert)
#ifndef MENUQC
vector get_corner_position(entity box, int corner)