dot_qq_test.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.
  2. //Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #include <boost/qvm/quat_operations.hpp>
  5. #include "test_qvm_quaternion.hpp"
  6. #include "gold.hpp"
  7. namespace
  8. {
  9. template <class T,class U> struct same_type_tester;
  10. template <class T> struct same_type_tester<T,T> { };
  11. template <class T,class U> void test_same_type( T, U ) { same_type_tester<T,U>(); }
  12. void
  13. test()
  14. {
  15. using namespace boost::qvm::sfinae;
  16. test_qvm::quaternion<Q1> const x(42,1);
  17. {
  18. test_qvm::quaternion<Q1> const y(43,1);
  19. test_same_type(float(),dot(x,y));
  20. float d1=dot(x,y);
  21. float d2=test_qvm::dot<float>(x.a,y.a);
  22. BOOST_QVM_TEST_CLOSE(d1,d2,0.000001f);
  23. }
  24. {
  25. test_qvm::quaternion<Q1,double> const y(43,1);
  26. test_same_type(double(),dot(x,y));
  27. double d1=dot(x,y);
  28. double d2=test_qvm::dot<double>(x.a,y.a);
  29. BOOST_QVM_TEST_CLOSE(d1,d2,0.000001);
  30. }
  31. }
  32. }
  33. int
  34. main()
  35. {
  36. test();
  37. return boost::report_errors();
  38. }