up = v_up; \
} MACRO_END
+//pseudo prototypes:
+// vector vec2(vector v); // returns a vector with just the x and y components of the given vector
+// vector vec2(float x, float y); // returns a vector with the given x and y components
+
noref vector _vec2;
#define vec2(...) EVAL(OVERLOAD(vec2, __VA_ARGS__))
#define vec2_1(v) (_vec2 = (v), _vec2.z = 0, _vec2)
vector Rotate(vector v, float a)
{
float a_sin = sin(a), a_cos = cos(a);
- vector r = '0 0 0';
- r.x = v.x * a_cos + v.y * a_sin;
- r.y = -1 * v.x * a_sin + v.y * a_cos;
- return r;
+ return vec2(v.x * a_cos + v.y * a_sin, -v.x * a_sin + v.y * a_cos);
}
noref vector _yinvert;
vector m1 = box.mins + box.origin;
vector m2 = box.maxs + box.origin;
- vector ret;
- ret.x = bound(m1.x, org.x, m2.x);
- ret.y = bound(m1.y, org.y, m2.y);
- ret.z = bound(m1.z, org.z, m2.z);
- return ret;
+ return vec3(
+ bound(m1.x, org.x, m2.x),
+ bound(m1.y, org.y, m2.y),
+ bound(m1.z, org.z, m2.z)
+ );
}
#endif