cross_test.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/vec_operations.hpp>
  5. #include <boost/qvm/vec_access.hpp>
  6. #include <boost/qvm/mat_access.hpp>
  7. #include <boost/qvm/vec_operations3.hpp>
  8. #include <boost/qvm/vec.hpp>
  9. //#include <boost/qvm/quat_traits.hpp>
  10. #include "test_qvm_vector.hpp"
  11. #include "test_qvm_matrix.hpp"
  12. #include "gold.hpp"
  13. namespace
  14. {
  15. template <class T,class U> struct same_type_tester;
  16. template <class T> struct same_type_tester<T,T> { };
  17. template <class T,class U> void test_same_type( T, U ) { same_type_tester<T,U>(); }
  18. }
  19. int
  20. main()
  21. {
  22. using namespace boost::qvm;
  23. test_qvm::vector<V1,3> x(42,1);
  24. test_qvm::vector<V1,3> y=x*2;
  25. test_qvm::matrix<M1,3,3> m;
  26. A00(m) = 0;
  27. A01(m) = -A2(x);
  28. A02(m) = A1(x);
  29. A10(m) = A2(x);
  30. A11(m) = 0;
  31. A12(m) = -A0(x);
  32. A20(m) = -A1(x);
  33. A21(m) = A0(x);
  34. A22(m) = 0;
  35. {
  36. test_same_type(x,cross(x,y));
  37. test_qvm::vector<V1,3> c=cross(x,y);
  38. test_qvm::multiply_mv(c.b,m.a,y.a);
  39. BOOST_QVM_TEST_EQ(c.a,c.b);
  40. }
  41. {
  42. test_qvm::vector<V2,3> c=cross(vref(x),y);
  43. test_qvm::multiply_mv(c.b,m.a,y.a);
  44. BOOST_QVM_TEST_EQ(c.a,c.b);
  45. }
  46. {
  47. test_qvm::vector<V2,3> c=cross(x,vref(y));
  48. test_qvm::multiply_mv(c.b,m.a,y.a);
  49. BOOST_QVM_TEST_EQ(c.a,c.b);
  50. }
  51. return boost::report_errors();
  52. }