3 #include "testing/testing.h"
13 TEST(abc_matrix, CreateRotationMatrixY_YfromZ)
16 float rot_x_mat[3][3];
17 float rot_y_mat[3][3];
18 float rot_z_mat[3][3];
19 float euler[3] = {0.0f,
M_PI_4, 0.0f};
23 float rot_z_min_quart_pi[3][3];
35 EXPECT_M3_NEAR(rot_x_mat, unit, 1e-5f);
36 EXPECT_M3_NEAR(rot_y_mat, unit, 1e-5f);
37 EXPECT_M3_NEAR(rot_z_mat, rot_z_min_quart_pi, 1e-5f);
40 TEST(abc_matrix, CreateRotationMatrixZ_YfromZ)
43 float rot_x_mat[3][3];
44 float rot_y_mat[3][3];
45 float rot_z_mat[3][3];
46 float euler[3] = {0.0f, 0.0f,
M_PI_4};
50 float rot_y_quart_pi[3][3];
62 EXPECT_M3_NEAR(rot_x_mat, unit, 1e-5f);
63 EXPECT_M3_NEAR(rot_y_mat, rot_y_quart_pi, 1e-5f);
64 EXPECT_M3_NEAR(rot_z_mat, unit, 1e-5f);
67 TEST(abc_matrix, CreateRotationMatrixXYZ_YfromZ)
70 float rot_x_mat[3][3];
71 float rot_y_mat[3][3];
72 float rot_z_mat[3][3];
74 float euler[3] = {0.17453292012214f, 0.34906581044197f, 0.52359879016876f};
77 float rot_x_p10[3][3];
78 float rot_y_p30[3][3];
79 float rot_z_m20[3][3];
82 rot_x_p10[1][1] = 0.9848077297210693f;
83 rot_x_p10[1][2] = 0.1736481785774231f;
84 rot_x_p10[2][1] = -0.1736481785774231f;
85 rot_x_p10[2][2] = 0.9848077297210693f;
88 rot_y_p30[0][0] = 0.8660253882408142f;
89 rot_y_p30[0][2] = -0.5f;
90 rot_y_p30[2][0] = 0.5f;
91 rot_y_p30[2][2] = 0.8660253882408142f;
94 rot_z_m20[0][0] = 0.9396926164627075f;
95 rot_z_m20[0][1] = -0.3420201241970062f;
96 rot_z_m20[1][0] = 0.3420201241970062f;
97 rot_z_m20[1][1] = 0.9396926164627075f;
102 EXPECT_M3_NEAR(rot_x_mat, rot_x_p10, 1e-5f);
103 EXPECT_M3_NEAR(rot_y_mat, rot_y_p30, 1e-5f);
104 EXPECT_M3_NEAR(rot_z_mat, rot_z_m20, 1e-5f);
107 TEST(abc_matrix, CreateRotationMatrixXYZ_ZfromY)
110 float rot_x_mat[3][3];
111 float rot_y_mat[3][3];
112 float rot_z_mat[3][3];
114 float euler[3] = {0.1745329201221466f, 0.3490658104419708f, 0.5235987901687622f};
117 float rot_x_p10[3][3];
118 float rot_y_m30[3][3];
119 float rot_z_p20[3][3];
122 rot_x_p10[1][1] = 0.9848077297210693f;
123 rot_x_p10[1][2] = 0.1736481785774231f;
124 rot_x_p10[2][1] = -0.1736481785774231f;
125 rot_x_p10[2][2] = 0.9848077297210693f;
128 rot_y_m30[0][0] = 0.8660253882408142f;
129 rot_y_m30[0][2] = 0.5f;
130 rot_y_m30[2][0] = -0.5f;
131 rot_y_m30[2][2] = 0.8660253882408142f;
134 rot_z_p20[0][0] = 0.9396926164627075f;
135 rot_z_p20[0][1] = 0.3420201241970062f;
136 rot_z_p20[1][0] = -0.3420201241970062f;
137 rot_z_p20[1][1] = 0.9396926164627075f;
142 EXPECT_M3_NEAR(rot_x_mat, rot_x_p10, 1e-5f);
143 EXPECT_M3_NEAR(rot_y_mat, rot_y_m30, 1e-5f);
144 EXPECT_M3_NEAR(rot_z_mat, rot_z_p20, 1e-5f);
147 TEST(abc_matrix, CopyM44AxisSwap_YfromZ)
154 float input[4][4] = {
155 {0.81379765272f, 0.4698463380336f, -0.342020124197f, 0.0f},
156 {-0.44096961617f, 0.8825641274452f, 0.163175910711f, 0.0f},
157 {0.37852230668f, 0.0180283170193f, 0.925416588783f, 0.0f},
158 {1.0f, 2.0f, 3.0f, 1.0f},
164 float trans[4] = {1.0f, 3.0f, -2.0f, 1.0f};
165 EXPECT_V4_NEAR(trans,
result[3], 1e-5f);
169 float expect[4][4] = {
170 {0.813797652721f, -0.342020124197f, -0.469846338033f, 0.0f},
171 {0.378522306680f, 0.925416588783f, -0.018028317019f, 0.0f},
172 {0.440969616174f, -0.163175910711f, 0.882564127445f, 0.0f},
173 {1.0f, 3.0f, -2.0f, 1.0f},
175 EXPECT_M4_NEAR(expect,
result, 1e-5f);
178 TEST(abc_matrix, CopyM44AxisSwapWithScale_YfromZ)
186 float input[4][4] = {
187 {3.25519061088f, 1.8793853521347f, -1.368080496788f, 0.0f},
188 {-2.20484805107f, 4.4128208160400f, 0.815879583358f, 0.0f},
189 {2.27113389968f, 0.1081698983907f, 5.552499771118f, 0.0f},
190 {1.0f, 2.0f, 3.0f, 1.0f},
198 float expect[4][4] = {
199 {3.255190610885f, -1.368080496788f, -1.879385352134f, 0.0f},
200 {2.271133899688f, 5.552499771118f, -0.108169898390f, 0.0f},
201 {2.204848051071f, -0.815879583358f, 4.412820816040f, 0.0f},
202 {1.0f, 3.0f, -2.0f, 1.0f},
204 EXPECT_M4_NEAR(expect,
result, 1e-5f);
207 TEST(abc_matrix, CopyM44AxisSwap_ZfromY)
213 float input[4][4] = {
214 {0.813797652721f, -0.342020124197f, -0.469846338033f, 0.0f},
215 {0.378522306680f, 0.925416588783f, -0.018028317019f, 0.0f},
216 {0.440969616174f, -0.163175910711f, 0.882564127445f, 0.0f},
217 {1.0f, 3.0f, -2.0f, 1.0f},
224 float expect[4][4] = {
225 {0.813797652721f, 0.469846338033f, -0.342020124197f, 0.0f},
226 {-0.44096961617f, 0.882564127445f, 0.163175910711f, 0.0f},
227 {0.378522306680f, 0.018028317019f, 0.925416588783f, 0.0f},
228 {1.0f, 2.0f, 3.0f, 1.0f},
231 EXPECT_M4_NEAR(expect,
result, 1e-5f);
234 TEST(abc_matrix, CopyM44AxisSwapWithScale_ZfromY)
241 float input[4][4] = {
242 {3.2551906108f, -1.36808049678f, -1.879385352134f, 0.0f},
243 {2.2711338996f, 5.55249977111f, -0.108169898390f, 0.0f},
244 {2.2048480510f, -0.81587958335f, 4.412820816040f, 0.0f},
245 {1.0f, 3.0f, -2.0f, 1.0f},
253 float expect[4][4] = {
254 {3.25519061088f, 1.879385352134f, -1.36808049678f, 0.0f},
255 {-2.2048480510f, 4.412820816040f, 0.81587958335f, 0.0f},
256 {2.27113389968f, 0.108169898390f, 5.55249977111f, 0.0f},
257 {1.0f, 2.0f, 3.0f, 1.0f},
260 EXPECT_M4_NEAR(expect,
result, 1e-5f);
263 TEST(abc_matrix, CopyM44AxisSwapWithScale_gimbal_ZfromY)
269 float input[4][4] = {
270 {1.000f, 0.000f, 0.000f, 0.000f},
271 {0.000f, 0.000f, -1.000f, 0.000f},
272 {0.000f, 1.000f, 0.000f, 0.000f},
273 {-0.000f, -0.100f, -0.000f, 1.000f},
280 float expect[4][4] = {
281 {1.000f, 0.000f, 0.000f, 0.000f},
282 {0.000f, 0.000f, -1.000f, 0.000f},
283 {0.000f, 1.000f, 0.000f, 0.000f},
284 {-0.000f, 0.000f, -0.100f, 1.000f},
287 EXPECT_M4_NEAR(expect,
result, 1e-5f);
void unit_m3(float m[3][3])
ccl_global KernelShaderEvalInput * input
void create_swapped_rotation_matrix(float rot_x_mat[3][3], float rot_y_mat[3][3], float rot_z_mat[3][3], const float euler[3], AbcAxisSwapMode mode)
void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode)
TEST(abc_matrix, CreateRotationMatrixY_YfromZ)