]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/qvm/test/rot_mat_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / qvm / test / rot_mat_test.cpp
1 //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.
2
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #include <boost/qvm/mat_operations.hpp>
7 #include "test_qvm_matrix.hpp"
8 #include "test_qvm_vector.hpp"
9 #include "gold.hpp"
10
11 namespace
12 {
13 template <int D>
14 void
15 test_x()
16 {
17 using namespace boost::qvm;
18 test_qvm::vector<V1,3> axis; axis.a[0]=1;
19 for( float r=0; r<6.28f; r+=0.5f )
20 {
21 test_qvm::matrix<M1,D,D> const m1=rot_mat<D>(axis,r);
22 test_qvm::rotation_x(m1.b,r);
23 BOOST_QVM_TEST_EQ(m1.a,m1.b);
24 test_qvm::matrix<M1,D,D> m2(42,1);
25 set_rot(m2,axis,r);
26 test_qvm::rotation_x(m2.b,r);
27 BOOST_QVM_TEST_EQ(m2.a,m2.b);
28 test_qvm::matrix<M1,D,D> m3(42,1);
29 test_qvm::matrix<M1,D,D> m4(42,1);
30 rotate(m3,axis,r);
31 m3 = m3*m1;
32 BOOST_QVM_TEST_EQ(m3.a,m3.a);
33 }
34 }
35
36 template <int D>
37 void
38 test_y()
39 {
40 using namespace boost::qvm;
41 test_qvm::vector<V1,3> axis; axis.a[1]=1;
42 for( float r=0; r<6.28f; r+=0.5f )
43 {
44 test_qvm::matrix<M1,D,D> m1=rot_mat<D>(axis,r);
45 test_qvm::rotation_y(m1.b,r);
46 BOOST_QVM_TEST_EQ(m1.a,m1.b);
47 test_qvm::matrix<M1,D,D> m2(42,1);
48 set_rot(m2,axis,r);
49 test_qvm::rotation_y(m2.b,r);
50 BOOST_QVM_TEST_EQ(m2.a,m2.b);
51 test_qvm::matrix<M1,D,D> m3(42,1);
52 test_qvm::matrix<M1,D,D> m4(42,1);
53 rotate(m3,axis,r);
54 m3 = m3*m1;
55 BOOST_QVM_TEST_EQ(m3.a,m3.a);
56 }
57 }
58
59 template <int D>
60 void
61 test_z()
62 {
63 using namespace boost::qvm;
64 test_qvm::vector<V1,3> axis; axis.a[2]=1;
65 for( float r=0; r<6.28f; r+=0.5f )
66 {
67 test_qvm::matrix<M1,D,D> m1=rot_mat<D>(axis,r);
68 test_qvm::rotation_z(m1.b,r);
69 BOOST_QVM_TEST_EQ(m1.a,m1.b);
70 test_qvm::matrix<M1,D,D> m2(42,1);
71 set_rot(m2,axis,r);
72 test_qvm::rotation_z(m2.b,r);
73 BOOST_QVM_TEST_EQ(m2.a,m2.b);
74 test_qvm::matrix<M1,D,D> m3(42,1);
75 test_qvm::matrix<M1,D,D> m4(42,1);
76 rotate(m3,axis,r);
77 m3 = m3*m1;
78 BOOST_QVM_TEST_EQ(m3.a,m3.a);
79 }
80 }
81 }
82
83 int
84 main()
85 {
86 test_x<3>();
87 test_y<3>();
88 test_z<3>();
89 test_x<4>();
90 test_y<4>();
91 test_z<4>();
92 test_x<5>();
93 test_y<5>();
94 test_z<5>();
95 return boost::report_errors();
96 }