#ifndef Magnum_DimensionTraits_h #define Magnum_DimensionTraits_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. */ #include "Math/Math.h" #include "Types.h" /** @file * @brief Class Magnum::DimensionTraits */ namespace Magnum { /** @brief Matrix, point and vector specializations for given dimension count */ template struct DimensionTraits { DimensionTraits() = delete; #ifdef DOXYGEN_GENERATING_OUTPUT /** * @brief Vector type * * Math::Vector, Math::Vector2 or Math::Vector3 based on dimension count. */ typedef U VectorType; /** * @brief Matrix type * * Floating-point Math::Matrix3 or Math::Matrix4 for 2D or 3D. No matrix * type defined for one dimension and integral types. */ typedef U MatrixType; #endif }; #ifndef DOXYGEN_GENERATING_OUTPUT /* One dimension */ template struct DimensionTraits<1, T> { DimensionTraits() = delete; typedef Math::Vector<1, T> VectorType; }; /* Two dimensions - integral */ template struct DimensionTraits<2, T> { DimensionTraits() = delete; typedef Math::Vector2 VectorType; }; /* Two dimensions - floating-point */ template<> struct DimensionTraits<2, Float> { DimensionTraits() = delete; typedef Math::Vector2 VectorType; typedef Math::Matrix3 MatrixType; }; template<> struct DimensionTraits<2, Double> { DimensionTraits() = delete; typedef Math::Vector2 VectorType; typedef Math::Matrix3 MatrixType; }; /* Three dimensions - integral */ template struct DimensionTraits<3, T> { DimensionTraits() = delete; typedef Math::Vector3 VectorType; }; /* Three dimensions - floating-point */ template<> struct DimensionTraits<3, Float> { DimensionTraits() = delete; typedef Math::Vector3 VectorType; typedef Math::Matrix4 MatrixType; }; template<> struct DimensionTraits<3, Double> { DimensionTraits() = delete; typedef Math::Vector3 VectorType; typedef Math::Matrix4 MatrixType; }; #endif } #endif