translation_test.cpp 1.0 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/vec_operations.hpp>
  5. #include <boost/qvm/vec.hpp>
  6. #include <boost/qvm/map_mat_vec.hpp>
  7. #include "test_qvm_matrix.hpp"
  8. #include "test_qvm_vector.hpp"
  9. #include "gold.hpp"
  10. namespace
  11. {
  12. template <int D>
  13. void
  14. test()
  15. {
  16. using namespace boost::qvm;
  17. test_qvm::matrix<M1,D,D> x(42,1);
  18. test_qvm::vector<V1,D-1> y=translation(x);
  19. for( int i=0; i!=D-1; ++i )
  20. y.b[i]=x.a[i][D-1];
  21. BOOST_QVM_TEST_EQ(y.a,y.b);
  22. translation(x) *= 2;
  23. for( int i=0; i!=D-1; ++i )
  24. x.b[i][D-1] *= 2;
  25. BOOST_QVM_TEST_EQ(x.a,x.b);
  26. translation(x) + translation(x);
  27. -translation(x);
  28. }
  29. }
  30. int
  31. main()
  32. {
  33. test<3>();
  34. test<4>();
  35. test<5>();
  36. return boost::report_errors();
  37. }