Browse Source

Shapes: fixed 2D Capsule transformation.

The test now passes again.
pull/23/head
Vladimír Vondruš 13 years ago
parent
commit
e7dbe606cd
  1. 14
      src/Shapes/Capsule.cpp

14
src/Shapes/Capsule.cpp

@ -36,9 +36,21 @@ using namespace Magnum::Math::Geometry;
namespace Magnum { namespace Shapes {
namespace {
template<UnsignedInt dimensions> static typename DimensionTraits<dimensions, Float>::VectorType unitVector();
template<> inline Vector2 unitVector<2>() {
return Vector2(1/Constants::sqrt2());
}
template<> inline Vector3 unitVector<3>() {
return Vector3(1/Constants::sqrt3());
}
}
template<UnsignedInt dimensions> Capsule<dimensions> Capsule<dimensions>::transformed(const typename DimensionTraits<dimensions, Float>::MatrixType& matrix) const {
return Capsule<dimensions>(matrix.transformPoint(_a), matrix.transformPoint(_b),
(matrix.rotationScaling()*typename DimensionTraits<dimensions, Float>::VectorType(1/Constants::sqrt3())).length()*_radius);
(matrix.rotationScaling()*unitVector<dimensions>()).length()*_radius);
}
template<UnsignedInt dimensions> bool Capsule<dimensions>::operator%(const Point<dimensions>& other) const {

Loading…
Cancel
Save