Browse Source

Math: clarify that implicit conversion of Foo to a DualFoo is rotation.

Had to remind myself about that.
pull/420/head
Vladimír Vondruš 6 years ago
parent
commit
ea92c5b36f
  1. 7
      src/Magnum/Math/DualComplex.h
  2. 7
      src/Magnum/Math/DualQuaternion.h
  3. 3
      src/Magnum/Math/Test/DualComplexTest.cpp
  4. 3
      src/Magnum/Math/Test/DualQuaternionTest.cpp

7
src/Magnum/Math/DualComplex.h

@ -67,6 +67,10 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @f[ * @f[
* \hat c = (\cos(\theta) + i \sin(\theta)) + \epsilon (0 + i0) * \hat c = (\cos(\theta) + i \sin(\theta)) + \epsilon (0 + i0)
* @f] * @f]
*
* For creating a dual complex number from a rotation @ref Complex, use
* the implicit conversion provided by
* @ref DualComplex(const Complex<T>&, const Complex<T>&).
* @see @ref Complex::rotation(), @ref Matrix3::rotation(), * @see @ref Complex::rotation(), @ref Matrix3::rotation(),
* @ref DualQuaternion::rotation() * @ref DualQuaternion::rotation()
*/ */
@ -130,6 +134,9 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @f[ * @f[
* \hat c = c_0 + \epsilon c_\epsilon * \hat c = c_0 + \epsilon c_\epsilon
* @f] * @f]
*
* This constructor can be also used to implicitly convert a rotation
* complex number to a rotation dual complex number.
*/ */
constexpr /*implicit*/ DualComplex(const Complex<T>& real, const Complex<T>& dual = Complex<T>(T(0), T(0))) noexcept: Dual<Complex<T>>(real, dual) {} constexpr /*implicit*/ DualComplex(const Complex<T>& real, const Complex<T>& dual = Complex<T>(T(0), T(0))) noexcept: Dual<Complex<T>>(real, dual) {}

7
src/Magnum/Math/DualQuaternion.h

@ -200,6 +200,10 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
* Expects that the rotation axis is normalized. @f[ * Expects that the rotation axis is normalized. @f[
* \hat q = [\boldsymbol a \cdot \sin(\frac{\theta}{2}), \cos(\frac{\theta}{2})] + \epsilon [\boldsymbol 0, 0] * \hat q = [\boldsymbol a \cdot \sin(\frac{\theta}{2}), \cos(\frac{\theta}{2})] + \epsilon [\boldsymbol 0, 0]
* @f] * @f]
*
* For creating a dual quaternion from a rotation @ref Quaternion, use
* the implicit conversion provided by
* @ref DualQuaternion(const Quaternion<T>&, const Quaternion<T>&).
* @see @ref rotation() const, @ref Quaternion::rotation(), * @see @ref rotation() const, @ref Quaternion::rotation(),
* @ref Matrix4::rotation(), @ref DualComplex::rotation(), * @ref Matrix4::rotation(), @ref DualComplex::rotation(),
* @ref Vector3::xAxis(), @ref Vector3::yAxis(), * @ref Vector3::xAxis(), @ref Vector3::yAxis(),
@ -270,6 +274,9 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
* @f[ * @f[
* \hat q = q_0 + \epsilon q_\epsilon * \hat q = q_0 + \epsilon q_\epsilon
* @f] * @f]
*
* This constructor can be also used to implicitly convert a rotation
* quaternion to a rotation dual quaternion.
*/ */
constexpr /*implicit*/ DualQuaternion(const Quaternion<T>& real, const Quaternion<T>& dual = Quaternion<T>({}, T(0))) noexcept: Dual<Quaternion<T>>(real, dual) {} constexpr /*implicit*/ DualQuaternion(const Quaternion<T>& real, const Quaternion<T>& dual = Quaternion<T>({}, T(0))) noexcept: Dual<Quaternion<T>>(real, dual) {}

3
src/Magnum/Math/Test/DualComplexTest.cpp

@ -395,6 +395,9 @@ void DualComplexTest::rotation() {
constexpr DualComplex b({-1.0f, 2.0f}, {}); constexpr DualComplex b({-1.0f, 2.0f}, {});
constexpr Complex c = b.rotation(); constexpr Complex c = b.rotation();
CORRADE_COMPARE(c, Complex(-1.0f, 2.0f)); CORRADE_COMPARE(c, Complex(-1.0f, 2.0f));
/* Conversion from a rotation complex should give the same result */
CORRADE_COMPARE(DualComplex{Complex::rotation(120.0_degf)}, a);
} }
void DualComplexTest::translation() { void DualComplexTest::translation() {

3
src/Magnum/Math/Test/DualQuaternionTest.cpp

@ -434,6 +434,9 @@ void DualQuaternionTest::rotation() {
constexpr DualQuaternion b({{-1.0f, 2.0f, 3.0f}, 4.0f}, {}); constexpr DualQuaternion b({{-1.0f, 2.0f, 3.0f}, 4.0f}, {});
constexpr Quaternion c = b.rotation(); constexpr Quaternion c = b.rotation();
CORRADE_COMPARE(c, Quaternion({-1.0f, 2.0f, 3.0f}, 4.0f)); CORRADE_COMPARE(c, Quaternion({-1.0f, 2.0f, 3.0f}, 4.0f));
/* Conversion from a rotation quaternion should give the same result */
CORRADE_COMPARE(DualQuaternion{Quaternion::rotation(120.0_degf, axis)}, q);
} }
void DualQuaternionTest::rotationNotNormalized() { void DualQuaternionTest::rotationNotNormalized() {

Loading…
Cancel
Save