#ifndef Magnum_Math_Matrix3_h #define Magnum_Math_Matrix3_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš This file is part of Magnum. Magnum is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. Magnum is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details. */ /** @file * @brief Class Magnum::Math::Matrix3 */ #include "Matrix.h" #include "Vector3.h" namespace Magnum { namespace Math { /** @brief 3x3 matrix */ template class Matrix3: public Matrix { public: /** @copydoc Matrix::from(T*) */ inline constexpr static Matrix3& from(T* data) { return *reinterpret_cast*>(data); } /** @copydoc Matrix::from(const T*) */ inline constexpr static const Matrix3& from(const T* data) { return *reinterpret_cast*>(data); } /** @copydoc Matrix::from(const Vector&, const U&...) */ template inline constexpr static Matrix3 from(const Vector& first, const U&... next) { return Matrix::from(first, next...); } /** @copydoc Matrix::Matrix(ZeroType) */ inline constexpr explicit Matrix3(typename Matrix::ZeroType): Matrix(Matrix::Zero) {} /** @copydoc Matrix::Matrix(IdentityType) */ inline constexpr explicit Matrix3(typename Matrix::IdentityType = Matrix::Identity, T value = T(1)): Matrix{ /** @todo Make this in Matrix itself, after it will be constexpr */ value, 0.0f, 0.0f, 0.0f, value, 0.0f, 0.0f, 0.0f, value } {} #ifndef DOXYGEN_GENERATING_OUTPUT template explicit Matrix3(U) = delete; #endif /** @copydoc Matrix::Matrix(T, U...) */ #ifndef DOXYGEN_GENERATING_OUTPUT template inline constexpr Matrix3(T first, U... next): Matrix(first, next...) {} #else template inline constexpr Matrix3(T first, U... next) {} #endif /** @copydoc Matrix::Matrix(const Matrix&) */ inline constexpr Matrix3(const Matrix& other): Matrix(other) {} /** @copydoc Matrix::operator=() */ inline constexpr Matrix3& operator=(const Matrix& other) { return Matrix::operator=(other); } /** @copydoc Matrix::operator[](size_t) */ inline Vector3& operator[](size_t col) { return Vector3::from(Matrix::data()+col*3); } /** @copydoc Matrix::operator[](size_t) const */ inline constexpr const Vector3& operator[](size_t col) const { return Vector3::from(Matrix::data()+col*3); } /** @copydoc Matrix::operator*(const Matrix&) const */ inline Matrix3 operator*(const Matrix& other) const { return Matrix::operator*(other); } /** @copydoc Matrix::operator*=() */ inline Matrix3& operator*=(const Matrix& other) { Matrix::operator*=(other); return *this; } /** @copydoc Matrix::operator*(const Vector&) const */ inline Vector3 operator*(const Vector& other) const { return Matrix::operator*(other); } /** @copydoc Matrix::transposed() */ inline Matrix3 transposed() const { return Matrix::transposed(); } /** @copydoc Matrix::inversed() */ inline Matrix3 inversed() const { return Matrix::inversed(); } }; #ifndef DOXYGEN_GENERATING_OUTPUT template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Matrix3& value) { return debug << static_cast&>(value); } #endif }} #endif