#ifndef SPECTRE_MATH_VECTOR4_H #define SPECTRE_MATH_VECTOR4_H #include namespace sp { template struct Vector4 { union { struct { T x, y, z, w; }; T v[4]; }; inline Vector4(); inline Vector4(T s); inline Vector4(T x, T y, T z); inline Vector4(T x, T y, T z, T w); template inline Vector4(const Vector4& vec); // Named operations inline float length() const; inline Vector4& normalize(); }; // --------- // Compare // --------- template inline bool operator==(const Vector4& a, const Vector4& b); template inline bool operator!=(const Vector4& a, const Vector4& b); template inline bool operator<(const Vector4& a, const Vector4& b); template inline bool operator<=(const Vector4& a, const Vector4& b); template inline bool operator>(const Vector4& a, const Vector4& b); template inline bool operator>=(const Vector4& a, const Vector4& b); // ------------ // Arithmetic // ------------ template inline Vector4 operator+(const Vector4& a, const Vector4& b); template inline Vector4 operator-(const Vector4& a, const Vector4& b); template inline Vector4 operator/(const Vector4& a, const Vector4& b); template inline Vector4 operator*(const Vector4& a, const Vector4& b); template inline Vector4& operator+=(Vector4& a, const Vector4& b); template inline Vector4& operator-=(Vector4& a, const Vector4& b); template inline Vector4& operator/=(Vector4& a, const Vector4& b); template inline Vector4& operator*=(Vector4& a, const Vector4& b); // ------------------- // Scalar Arithmetic // ------------------- template inline Vector4 operator+(const Vector4& v, T s); template inline Vector4 operator+(T s, const Vector4& v); template inline Vector4 operator-(const Vector4& v, T s); template inline Vector4 operator-(T s, const Vector4& v); template inline Vector4 operator/(const Vector4& v, T s); template inline Vector4 operator/(T s, const Vector4& v); template inline Vector4 operator*(const Vector4& v, T s); template inline Vector4 operator*(T s, const Vector4& v); // ---------------- // Scalar compare // ---------------- template inline bool operator<(const Vector4& v, T s); template inline bool operator<(T s, const Vector4& v); template inline bool operator<=(const Vector4& v, T s); template inline bool operator<=(T s, const Vector4& v); template inline bool operator>(const Vector4& v, T s); template inline bool operator>(T s, const Vector4& v); template inline bool operator>=(const Vector4& v, T s); template inline bool operator>=(T s, const Vector4& v); // Stream template inline std::ostream& operator<<(std::ostream &s, const Vector4& v); typedef Vector4 Vector4f; typedef Vector4 Vector4i; typedef Vector4 Vector4u; typedef Vector4 Vector4b; typedef Vector4 vec4f; typedef Vector4 vec4i; typedef Vector4 vec4u; typedef Vector4 vec4b; } // namespace sp #include "Vector4.inl" #endif /* SPECTRE_MATH_VECTOR4_H */