inverse_q_test.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 <boost/qvm/quat.hpp>
  6. #include <boost/exception/diagnostic_information.hpp>
  7. #include "test_qvm_quaternion.hpp"
  8. #include "test_qvm.hpp"
  9. namespace
  10. {
  11. template <class T,class U> struct same_type_tester;
  12. template <class T> struct same_type_tester<T,T> { };
  13. template <class T,class U> void test_same_type( T, U ) { same_type_tester<T,U>(); }
  14. void
  15. test()
  16. {
  17. using namespace boost::qvm;
  18. test_qvm::quaternion<Q1> x=rotx_quat(4.2f);
  19. test_same_type(x,inverse(x));
  20. test_qvm::quaternion<Q1> y=rotx_quat(-4.2f);
  21. {
  22. test_qvm::quaternion<Q1> z=inverse(x);
  23. BOOST_QVM_TEST_CLOSE_QUAT(z.a,y.a,0.00001f);
  24. }
  25. {
  26. test_qvm::quaternion<Q1> z=inverse(qref(x));
  27. BOOST_QVM_TEST_CLOSE_QUAT(z.a,y.a,0.00001f);
  28. }
  29. }
  30. }
  31. int
  32. main()
  33. {
  34. test();
  35. return boost::report_errors();
  36. }