From e7dbe606cd47024fc2d87d0e8b801ac6c3a8b29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 18 Aug 2013 00:13:11 +0200 Subject: [PATCH] Shapes: fixed 2D Capsule transformation. The test now passes again. --- src/Shapes/Capsule.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 {