10 typedef std::vector<float> FloatArray;
29 return Vec4(1, 1, 1, 1);
33 x(0), y(0), z(0), w(0) {
36 Vec4(
const FloatArray& arr) :
37 x(arr[0]), y(arr[1]), z(arr[2]), w(arr[3]) {}
39 Vec4(
float x,
float y,
float z,
float w):
40 x(x), y(y), z(z), w(w) {
46 operator FloatArray()
const {
50 bool equals(
const Vec4& rhs)
const {
51 return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w;
54 bool operator==(
const Vec4& rhs)
const {
55 return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w;
58 bool operator!=(
const Vec4& rhs)
const {
59 return (x != rhs.x) || (y != rhs.y) || (z != rhs.z) || (w != rhs.w);
62 Vec4 operator+(
const Vec4& rhs)
const {
63 return Vec4(x + rhs.x, y + rhs.y, z + rhs.z, w + rhs.w);
66 Vec4 operator-(
const Vec4& rhs)
const {
67 return Vec4(x - rhs.x, y - rhs.y, z - rhs.z, w - rhs.w);
70 Vec4 operator*(
const float& rhs)
const {
79 float length()
const {
80 return fast_sqrt(length_squared());
83 float length_squared()
const {
85 return MATH_Sum_of_Squares(x, y, z, w);
92 float l = fast_inverse_sqrt(length_squared());
99 float dot(
const Vec4& rhs)
const {
101 return MATH_fipr(x, y, z, w, rhs.x, rhs.y, rhs.z, rhs.w);
103 return x * rhs.x + y * rhs.y + z * rhs.z + w * rhs.w;
117 std::ostream& operator<<(std::ostream& stream,
const Vec4& vec);