/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @ref core /// @file glm/core/type_tvec4.inl /// @date 2008-08-23 / 2011-06-15 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// namespace glm{ namespace detail { template GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tvec4::length() const { return 4; } ////////////////////////////////////// // Accesses template GLM_FUNC_QUALIFIER T & tvec4::operator[](length_t i) { assert(i >= 0 && i < this->length()); return (&x)[i]; } template GLM_FUNC_QUALIFIER T const & tvec4::operator[](length_t i) const { assert(i >= 0 && i < this->length()); return (&x)[i]; } ////////////////////////////////////// // Implicit basic constructors template GLM_FUNC_QUALIFIER tvec4::tvec4() : x(0), y(0), z(0), w(0) {} template GLM_FUNC_QUALIFIER tvec4::tvec4(tvec4 const & v) : x(v.x), y(v.y), z(v.z), w(v.w) {} template template GLM_FUNC_QUALIFIER tvec4::tvec4(tvec4 const & v) : x(v.x), y(v.y), z(v.z), w(v.w) {} ////////////////////////////////////// // Explicit basic constructors template GLM_FUNC_QUALIFIER tvec4::tvec4(ctor) {} template GLM_FUNC_QUALIFIER tvec4::tvec4(T const & s) : x(s), y(s), z(s), w(s) {} template GLM_FUNC_QUALIFIER tvec4::tvec4 ( T const & s1, T const & s2, T const & s3, T const & s4 ) : x(s1), y(s2), z(s3), w(s4) {} ////////////////////////////////////// // Conversion scalar constructors template template GLM_FUNC_QUALIFIER tvec4::tvec4 ( A const & x, B const & y, C const & z, D const & w ) : x(static_cast(x)), y(static_cast(y)), z(static_cast(z)), w(static_cast(w)) {} template template GLM_FUNC_QUALIFIER tvec4::tvec4 ( tvec4 const & v ) : x(static_cast(v.x)), y(static_cast(v.y)), z(static_cast(v.z)), w(static_cast(v.w)) {} ////////////////////////////////////// // Conversion vector constructors template template GLM_FUNC_QUALIFIER tvec4::tvec4 ( tvec2 const & v, B const & s1, C const & s2 ) : x(static_cast(v.x)), y(static_cast(v.y)), z(static_cast(s1)), w(static_cast(s2)) {} template template GLM_FUNC_QUALIFIER tvec4::tvec4 ( A const & s1, tvec2 const & v, C const & s2 ) : x(static_cast(s1)), y(static_cast(v.x)), z(static_cast(v.y)), w(static_cast(s2)) {} template template GLM_FUNC_QUALIFIER tvec4::tvec4 ( A const & s1, B const & s2, tvec2 const & v ) : x(static_cast(s1)), y(static_cast(s2)), z(static_cast(v.x)), w(static_cast(v.y)) {} template template GLM_FUNC_QUALIFIER tvec4::tvec4 ( tvec3 const & v, B const & s ) : x(static_cast(v.x)), y(static_cast(v.y)), z(static_cast(v.z)), w(static_cast(s)) {} template template GLM_FUNC_QUALIFIER tvec4::tvec4 ( A const & s, tvec3 const & v ) : x(static_cast(s)), y(static_cast(v.x)), z(static_cast(v.y)), w(static_cast(v.z)) {} template template GLM_FUNC_QUALIFIER tvec4::tvec4 ( tvec2 const & v1, tvec2 const & v2 ) : x(static_cast(v1.x)), y(static_cast(v1.y)), z(static_cast(v2.x)), w(static_cast(v2.y)) {} ////////////////////////////////////// // Unary arithmetic operators template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator= (tvec4 const & v) { this->x = v.x; this->y = v.y; this->z = v.z; this->w = v.w; return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator= (tvec4 const & v) { this->x = static_cast(v.x); this->y = static_cast(v.y); this->z = static_cast(v.z); this->w = static_cast(v.w); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (U s) { this->x += static_cast(s); this->y += static_cast(s); this->z += static_cast(s); this->w += static_cast(s); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator+= (tvec4 const & v) { this->x += static_cast(v.x); this->y += static_cast(v.y); this->z += static_cast(v.z); this->w += static_cast(v.w); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator-= (U s) { this->x -= static_cast(s); this->y -= static_cast(s); this->z -= static_cast(s); this->w -= static_cast(s); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator-= (tvec4 const & v) { this->x -= static_cast(v.x); this->y -= static_cast(v.y); this->z -= static_cast(v.z); this->w -= static_cast(v.w); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*= (U s) { this->x *= static_cast(s); this->y *= static_cast(s); this->z *= static_cast(s); this->w *= static_cast(s); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator*= (tvec4 const & v) { this->x *= static_cast(v.x); this->y *= static_cast(v.y); this->z *= static_cast(v.z); this->w *= static_cast(v.w); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/= (U s) { this->x /= static_cast(s); this->y /= static_cast(s); this->z /= static_cast(s); this->w /= static_cast(s); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator/= (tvec4 const & v) { this->x /= static_cast(v.x); this->y /= static_cast(v.y); this->z /= static_cast(v.z); this->w /= static_cast(v.w); return *this; } ////////////////////////////////////// // Increment and decrement operators template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator++() { ++this->x; ++this->y; ++this->z; ++this->w; return *this; } template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator--() { --this->x; --this->y; --this->z; --this->w; return *this; } template GLM_FUNC_QUALIFIER tvec4 tvec4::operator++(int) { tvec4 Result(*this); ++*this; return Result; } template GLM_FUNC_QUALIFIER tvec4 tvec4::operator--(int) { tvec4 Result(*this); --*this; return Result; } ////////////////////////////////////// // Unary bit operators template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator%= (U s) { this->x %= static_cast(s); this->y %= static_cast(s); this->z %= static_cast(s); this->w %= static_cast(s); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator%= (tvec4 const & v) { this->x %= static_cast(v.x); this->y %= static_cast(v.y); this->z %= static_cast(v.z); this->w %= static_cast(v.w); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator&= (U s) { this->x &= static_cast(s); this->y &= static_cast(s); this->z &= static_cast(s); this->w &= static_cast(s); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator&= (tvec4 const & v) { this->x &= static_cast(v.x); this->y &= static_cast(v.y); this->z &= static_cast(v.z); this->w &= static_cast(v.w); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator|= (U s) { this->x |= static_cast(s); this->y |= static_cast(s); this->z |= static_cast(s); this->w |= static_cast(s); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator|= (tvec4 const & v) { this->x |= static_cast(v.x); this->y |= static_cast(v.y); this->z |= static_cast(v.z); this->w |= static_cast(v.w); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator^= (U s) { this->x ^= static_cast(s); this->y ^= static_cast(s); this->z ^= static_cast(s); this->w ^= static_cast(s); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator^= (tvec4 const & v) { this->x ^= static_cast(v.x); this->y ^= static_cast(v.y); this->z ^= static_cast(v.z); this->w ^= static_cast(v.w); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator<<= (U s) { this->x <<= static_cast(s); this->y <<= static_cast(s); this->z <<= static_cast(s); this->w <<= static_cast(s); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator<<= (tvec4 const & v) { this->x <<= static_cast(v.x); this->y <<= static_cast(v.y); this->z <<= static_cast(v.z); this->w <<= static_cast(v.w); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator>>= (U s) { this->x >>= static_cast(s); this->y >>= static_cast(s); this->z >>= static_cast(s); this->w >>= static_cast(s); return *this; } template template GLM_FUNC_QUALIFIER tvec4 & tvec4::operator>>= (tvec4 const & v) { this->x >>= static_cast(v.x); this->y >>= static_cast(v.y); this->z >>= static_cast(v.z); this->w >>= static_cast(v.w); return *this; } ////////////////////////////////////// // Binary arithmetic operators template GLM_FUNC_QUALIFIER tvec4 operator+ ( tvec4 const & v, T const & s ) { return tvec4( v.x + s, v.y + s, v.z + s, v.w + s); } template GLM_FUNC_QUALIFIER tvec4 operator+ ( T const & s, tvec4 const & v ) { return tvec4( s + v.x, s + v.y, s + v.z, s + v.w); } template GLM_FUNC_QUALIFIER tvec4 operator+ ( tvec4 const & v1, tvec4 const & v2 ) { return tvec4( v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w); } //operator- template GLM_FUNC_QUALIFIER tvec4 operator- ( tvec4 const & v, T const & s ) { return tvec4( v.x - s, v.y - s, v.z - s, v.w - s); } template GLM_FUNC_QUALIFIER tvec4 operator- ( T const & s, tvec4 const & v ) { return tvec4( s - v.x, s - v.y, s - v.z, s - v.w); } template GLM_FUNC_QUALIFIER tvec4 operator- ( tvec4 const & v1, tvec4 const & v2 ) { return tvec4( v1.x - v2.x, v1.y - v2.y, v1.z - v2.z, v1.w - v2.w); } //operator* template GLM_FUNC_QUALIFIER tvec4 operator* ( tvec4 const & v, T const & s ) { return tvec4( v.x * s, v.y * s, v.z * s, v.w * s); } template GLM_FUNC_QUALIFIER tvec4 operator* ( T const & s, tvec4 const & v ) { return tvec4( s * v.x, s * v.y, s * v.z, s * v.w); } template GLM_FUNC_QUALIFIER tvec4 operator* ( tvec4 const & v1, tvec4 const & v2 ) { return tvec4( v1.x * v2.x, v1.y * v2.y, v1.z * v2.z, v1.w * v2.w); } //operator/ template GLM_FUNC_QUALIFIER tvec4 operator/ ( tvec4 const & v, T const & s ) { return tvec4( v.x / s, v.y / s, v.z / s, v.w / s); } template GLM_FUNC_QUALIFIER tvec4 operator/ ( T const & s, tvec4 const & v ) { return tvec4( s / v.x, s / v.y, s / v.z, s / v.w); } template GLM_FUNC_QUALIFIER tvec4 operator/ ( tvec4 const & v1, tvec4 const & v2 ) { return tvec4( v1.x / v2.x, v1.y / v2.y, v1.z / v2.z, v1.w / v2.w); } // Unary constant operators template GLM_FUNC_QUALIFIER tvec4 operator- ( tvec4 const & v ) { return tvec4( -v.x, -v.y, -v.z, -v.w); } ////////////////////////////////////// // Boolean operators template GLM_FUNC_QUALIFIER bool operator== ( tvec4 const & v1, tvec4 const & v2 ) { return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w); } template GLM_FUNC_QUALIFIER bool operator!= ( tvec4 const & v1, tvec4 const & v2 ) { return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z) || (v1.w != v2.w); } ////////////////////////////////////// // Binary bit operators template GLM_FUNC_QUALIFIER tvec4 operator% ( tvec4 const & v, T const & s ) { return tvec4( v.x % s, v.y % s, v.z % s, v.w % s); } template GLM_FUNC_QUALIFIER tvec4 operator% ( T const & s, tvec4 const & v ) { return tvec4( s % v.x, s % v.y, s % v.z, s % v.w); } template GLM_FUNC_QUALIFIER tvec4 operator% ( tvec4 const & v1, tvec4 const & v2 ) { return tvec4( v1.x % v2.x, v1.y % v2.y, v1.z % v2.z, v1.w % v2.w); } template GLM_FUNC_QUALIFIER tvec4 operator& ( tvec4 const & v, T const & s ) { return tvec4( v.x & s, v.y & s, v.z & s, v.w & s); } template GLM_FUNC_QUALIFIER tvec4 operator& ( T const & s, tvec4 const & v ) { return tvec4( s & v.x, s & v.y, s & v.z, s & v.w); } template GLM_FUNC_QUALIFIER tvec4 operator& ( tvec4 const & v1, tvec4 const & v2 ) { return tvec4( v1.x & v2.x, v1.y & v2.y, v1.z & v2.z, v1.w & v2.w); } template GLM_FUNC_QUALIFIER tvec4 operator| ( tvec4 const & v, T const & s ) { return tvec4( v.x | s, v.y | s, v.z | s, v.w | s); } template GLM_FUNC_QUALIFIER tvec4 operator| ( T const & s, tvec4 const & v ) { return tvec4( s | v.x, s | v.y, s | v.z, s | v.w); } template GLM_FUNC_QUALIFIER tvec4 operator| ( tvec4 const & v1, tvec4 const & v2 ) { return tvec4( v1.x | v2.x, v1.y | v2.y, v1.z | v2.z, v1.w | v2.w); } template GLM_FUNC_QUALIFIER tvec4 operator^ ( tvec4 const & v, T const & s ) { return tvec4( v.x ^ s, v.y ^ s, v.z ^ s, v.w ^ s); } template GLM_FUNC_QUALIFIER tvec4 operator^ ( T const & s, tvec4 const & v ) { return tvec4( s ^ v.x, s ^ v.y, s ^ v.z, s ^ v.w); } template GLM_FUNC_QUALIFIER tvec4 operator^ ( tvec4 const & v1, tvec4 const & v2 ) { return tvec4( v1.x ^ v2.x, v1.y ^ v2.y, v1.z ^ v2.z, v1.w ^ v2.w); } template GLM_FUNC_QUALIFIER tvec4 operator<< ( tvec4 const & v, T const & s ) { return tvec4( v.x << s, v.y << s, v.z << s, v.w << s); } template GLM_FUNC_QUALIFIER tvec4 operator<< ( T const & s, tvec4 const & v ) { return tvec4( s << v.x, s << v.y, s << v.z, s << v.w); } template GLM_FUNC_QUALIFIER tvec4 operator<< ( tvec4 const & v1, tvec4 const & v2 ) { return tvec4( v1.x << v2.x, v1.y << v2.y, v1.z << v2.z, v1.w << v2.w); } template GLM_FUNC_QUALIFIER tvec4 operator>> ( tvec4 const & v, T const & s ) { return tvec4( v.x >> s, v.y >> s, v.z >> s, v.w >> s); } template GLM_FUNC_QUALIFIER tvec4 operator>> ( T const & s, tvec4 const & v ) { return tvec4( s >> v.x, s >> v.y, s >> v.z, s >> v.w); } template GLM_FUNC_QUALIFIER tvec4 operator>> ( tvec4 const & v1, tvec4 const & v2 ) { return tvec4( v1.x >> v2.x, v1.y >> v2.y, v1.z >> v2.z, v1.w >> v2.w); } template GLM_FUNC_QUALIFIER tvec4 operator~ ( tvec4 const & v ) { return tvec4( ~v.x, ~v.y, ~v.z, ~v.w); } }//namespace detail }//namespace glm