diff --git a/src/Shapes/Capsule.cpp b/src/Shapes/Capsule.cpp index 497696d09..7fada2aee 100644 --- a/src/Shapes/Capsule.cpp +++ b/src/Shapes/Capsule.cpp @@ -36,9 +36,21 @@ using namespace Magnum::Math::Geometry; namespace Magnum { namespace Shapes { +namespace { + template static typename DimensionTraits::VectorType unitVector(); + + template<> inline Vector2 unitVector<2>() { + return Vector2(1/Constants::sqrt2()); + } + + template<> inline Vector3 unitVector<3>() { + return Vector3(1/Constants::sqrt3()); + } +} + template Capsule Capsule::transformed(const typename DimensionTraits::MatrixType& matrix) const { return Capsule(matrix.transformPoint(_a), matrix.transformPoint(_b), - (matrix.rotationScaling()*typename DimensionTraits::VectorType(1/Constants::sqrt3())).length()*_radius); + (matrix.rotationScaling()*unitVector()).length()*_radius); } template bool Capsule::operator%(const Point& other) const {