diff options
author | Gael Guennebaud <g.gael@free.fr> | 2011-01-27 11:33:37 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2011-01-27 11:33:37 +0100 |
commit | e8d6a5ca8787153c1b7e4b9d3f520ee85df5d5c7 (patch) | |
tree | 8485080488271dc2289aebd9bf0ef1a956178d3f /test/geo_orthomethods.cpp | |
parent | 0bfb78c8240525a8065e008efad08498d572ef81 (diff) |
fix cross product for complexes and add support for mixed real-complex cross products
Diffstat (limited to 'test/geo_orthomethods.cpp')
-rw-r--r-- | test/geo_orthomethods.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/geo_orthomethods.cpp b/test/geo_orthomethods.cpp index 9152d99c8..020ae7103 100644 --- a/test/geo_orthomethods.cpp +++ b/test/geo_orthomethods.cpp @@ -33,6 +33,7 @@ template<typename Scalar> void orthomethods_3() { + typedef typename NumTraits<Scalar>::Real RealScalar; typedef Matrix<Scalar,3,3> Matrix3; typedef Matrix<Scalar,3,1> Vector3; @@ -44,6 +45,9 @@ template<typename Scalar> void orthomethods_3() // cross product VERIFY_IS_MUCH_SMALLER_THAN(v1.cross(v2).dot(v1), Scalar(1)); + VERIFY_IS_MUCH_SMALLER_THAN(v1.dot(v1.cross(v2)), Scalar(1)); + VERIFY_IS_MUCH_SMALLER_THAN(v1.cross(v2).dot(v2), Scalar(1)); + VERIFY_IS_MUCH_SMALLER_THAN(v2.dot(v1.cross(v2)), Scalar(1)); Matrix3 mat3; mat3 << v0.normalized(), (v0.cross(v1)).normalized(), @@ -68,6 +72,12 @@ template<typename Scalar> void orthomethods_3() v40.w() = v41.w() = v42.w() = 0; v42.template head<3>() = v40.template head<3>().cross(v41.template head<3>()); VERIFY_IS_APPROX(v40.cross3(v41), v42); + + // check mixed product + typedef Matrix<RealScalar, 3, 1> RealVector3; + RealVector3 rv1 = RealVector3::Random(); + VERIFY_IS_APPROX(v1.cross(rv1.template cast<Scalar>()), v1.cross(rv1)); + VERIFY_IS_APPROX(rv1.template cast<Scalar>().cross(v1), rv1.cross(v1)); } template<typename Scalar, int Size> void orthomethods(int size=Size) @@ -115,6 +125,7 @@ void test_geo_orthomethods() for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1( orthomethods_3<float>() ); CALL_SUBTEST_2( orthomethods_3<double>() ); + CALL_SUBTEST_4( orthomethods_3<std::complex<double> >() ); CALL_SUBTEST_1( (orthomethods<float,2>()) ); CALL_SUBTEST_2( (orthomethods<double,2>()) ); CALL_SUBTEST_1( (orthomethods<float,3>()) ); |