-
Notifications
You must be signed in to change notification settings - Fork 67
/
Quaternion_TEST.py
540 lines (443 loc) · 19.1 KB
/
Quaternion_TEST.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
# Copyright (C) 2021 Open Source Robotics Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License")
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import math
import unittest
from ignition.math import Matrix3d
# TODO(ahcorde): Enable the corresponding tests when these classes
# are ported
# from ignition.math import Matrix4d
from ignition.math import Quaterniond
from ignition.math import Quaternionf
from ignition.math import Quaternioni
from ignition.math import Vector3d
class TestQuaternion(unittest.TestCase):
def test_construction(self):
q = Quaterniond(0, 0, 0, 1)
q2 = Quaterniond(q)
self.assertEqual(q2, q)
q3 = q
self.assertEqual(q3, q)
q4 = Quaterniond(q)
self.assertEqual(q4, q2)
q = q4
self.assertEqual(q, q2)
q5 = q2
self.assertEqual(q5, q3)
q2 = q5
self.assertEqual(q2, q3)
q6 = Quaterniond()
self.assertNotEqual(q6, q3)
def test_unit(self):
q = Quaterniond()
self.assertAlmostEqual(q.w(), 1.0)
self.assertAlmostEqual(q.x(), 0.0)
self.assertAlmostEqual(q.y(), 0.0)
self.assertAlmostEqual(q.z(), 0.0)
def test_construct_values(self):
q = Quaterniond(1.0, 2.0, 3.0, 4.0)
self.assertAlmostEqual(q.w(), 1.0)
self.assertAlmostEqual(q.x(), 2.0)
self.assertAlmostEqual(q.y(), 3.0)
self.assertAlmostEqual(q.z(), 4.0)
def test_construct_zero(self):
q = Quaterniond(0.0, 0.0, 0.0, 0.0)
self.assertAlmostEqual(q.w(), 0.0)
self.assertAlmostEqual(q.x(), 0.0)
self.assertAlmostEqual(q.y(), 0.0)
self.assertAlmostEqual(q.z(), 0.0)
qI = q.inverse()
self.assertAlmostEqual(qI.w(), 1.0)
self.assertAlmostEqual(qI.x(), 0.0)
self.assertAlmostEqual(qI.y(), 0.0)
self.assertAlmostEqual(qI.z(), 0.0)
def test_construct_euler(self):
q = Quaterniond(0, 1, 2)
self.assertAlmostEqual(q, Quaterniond(Vector3d(0, 1, 2)))
def test_construct_axis_angle(self):
q1 = Quaterniond(Vector3d(0, 0, 1), math.pi)
self.assertAlmostEqual(q1.x(), 0.0)
self.assertAlmostEqual(q1.y(), 0.0)
self.assertAlmostEqual(q1.z(), 1.0)
self.assertAlmostEqual(q1.w(), 0.0)
q = Quaterniond(q1)
self.assertTrue(q == q1)
def test_equal(self):
# double
q = Quaterniond(1, 2, 3, 4)
q2 = Quaterniond(1.01, 2.015, 3.002, 4.007)
self.assertTrue(q.equal(q2, 0.02))
self.assertFalse(q.equal(q2, 0.01))
# floats
q3 = Quaternionf(1, 2, 3, 4)
q4 = Quaternionf(1.05, 2.1, 3.03, 4.04)
self.assertTrue(q3.equal(q4, 0.2))
self.assertFalse(q3.equal(q4, 0.04))
# ints
q5 = Quaternioni(3, 5, -1, 9)
q6 = Quaternioni(3, 6, 1, 12)
self.assertTrue(q5.equal(q6, 3))
self.assertFalse(q5.equal(q6, 2))
def test_identity(self):
q = Quaterniond.IDENTITY
self.assertAlmostEqual(q.w(), 1.0)
self.assertAlmostEqual(q.x(), 0.0)
self.assertAlmostEqual(q.y(), 0.0)
self.assertAlmostEqual(q.z(), 0.0)
def test_mathlog(self):
q = Quaterniond(math.pi*0.1, math.pi*0.5, math.pi)
self.assertAlmostEqual(q.log(),
Quaterniond(0, -1.02593, 0.162491, 1.02593))
q1 = Quaterniond(q)
q1.w(2.0)
self.assertAlmostEqual(q1.log(),
Quaterniond(0, -0.698401, 0.110616, 0.698401))
def test_math_exp(self):
q = Quaterniond(math.pi*0.1, math.pi*0.5, math.pi)
self.assertAlmostEqual(q.exp(), Quaterniond(0.545456, -0.588972,
0.093284, 0.588972))
q1 = Quaterniond(q)
q1.x(0.000000001)
q1.y(0.0)
q1.z(0.0)
q1.w(0.0)
self.assertAlmostEqual(q1.exp(), Quaterniond(1, 0, 0, 0))
def test_math_invert(self):
q = Quaterniond(math.pi*0.1, math.pi*0.5, math.pi)
q.invert()
self.assertAlmostEqual(q, Quaterniond(0.110616, 0.698401,
-0.110616, -0.698401))
def test_math_axis(self):
q = Quaterniond(math.pi*0.1, math.pi*0.5, math.pi)
q.axis(0, 1, 0, math.pi)
self.assertAlmostEqual(q, Quaterniond(6.12303e-17, 0, 1, 0))
q.axis(Vector3d(1, 0, 0), math.pi)
self.assertAlmostEqual(q, Quaterniond(0, 1, 0, 0))
def test_math_set(self):
q = Quaterniond(math.pi*0.1, math.pi*0.5, math.pi)
q.set(1, 2, 3, 4)
self.assertAlmostEqual(q.w(), 1.0)
self.assertAlmostEqual(q.x(), 2.0)
self.assertAlmostEqual(q.y(), 3.0)
self.assertAlmostEqual(q.z(), 4.0)
def test_math_normalized(self):
q = Quaterniond(1, 2, 3, 4)
q2 = q.normalized()
self.assertAlmostEqual(q2, Quaterniond(0.182574, 0.365148,
0.547723, 0.730297))
def test_normalize(self):
q = Quaterniond(1, 2, 3, 4)
q.normalize()
self.assertAlmostEqual(q, Quaterniond(0.182574, 0.365148,
0.547723, 0.730297))
def test_math(self):
q = Quaterniond(math.pi*0.1, math.pi*0.5, math.pi)
self.assertTrue(q == Quaterniond(0.110616, -0.698401,
0.110616, 0.698401))
q.set(1, 2, 3, 4)
q.normalize()
self.assertAlmostEqual(q.roll(), 1.4289, delta=1e-3)
self.assertAlmostEqual(q.pitch(), -0.339837, delta=1e-3)
self.assertAlmostEqual(q.yaw(), 2.35619, delta=1e-3)
axis, angle = q.to_axis()
self.assertAlmostEqual(
axis, Vector3d(0.371391, 0.557086, 0.742781), delta=1e-3)
self.assertAlmostEqual(angle, 2.77438, delta=1e-3)
q.scale(0.1)
self.assertTrue(q == Quaterniond(0.990394, 0.051354,
0.0770309, 0.102708))
q = q + Quaterniond(0, 1, 2)
self.assertTrue(q == Quaterniond(1.46455, -0.352069,
0.336066, 0.841168))
q += q
self.assertTrue(q == Quaterniond(2.92911, -0.704137,
0.672131, 1.68234))
q -= Quaterniond(.4, .2, .1)
self.assertTrue(q == Quaterniond(1.95416, -0.896677, 0.56453, 1.65341))
q = q - Quaterniond(0, 1, 2)
self.assertTrue(q == Quaterniond(1.48, -0.493254,
0.305496, 0.914947))
q *= Quaterniond(.4, .1, .01)
self.assertTrue(q == Quaterniond(1.53584, -0.236801,
0.551841, 0.802979))
q = q * 5.0
self.assertTrue(q == Quaterniond(7.67918, -1.184, 2.7592, 4.0149))
self.assertTrue(q.rotate_vector_reverse(Vector3d(1, 2, 3)) ==
Vector3d(-0.104115, 0.4975, 3.70697))
self.assertAlmostEqual(q.dot(Quaterniond(.4, .2, .1)), 7.67183,
delta=1e-3)
self.assertTrue(Quaterniond.squad(1.1, Quaterniond(.1, 0, .2),
Quaterniond(0, .3, .4), Quaterniond(.5, .2, 1),
Quaterniond(0, 0, 2), True) ==
Quaterniond(0.346807, -0.0511734,
-0.0494723, 0.935232))
self.assertTrue(Quaterniond.euler_to_quaternion(
Vector3d(.1, .2, .3)) ==
Quaterniond(0.983347, 0.0342708,
0.106021, 0.143572))
q.round(2)
self.assertAlmostEqual(-1.18, q.x())
self.assertAlmostEqual(2.76, q.y())
self.assertAlmostEqual(4.01, q.z())
self.assertAlmostEqual(7.68, q.w())
q.x(0.0)
q.y(0.0)
q.z(0.0)
q.w(0.0)
q.normalize()
self.assertTrue(q == Quaterniond())
q.axis(0, 0, 0, 0)
self.assertTrue(q == Quaterniond())
self.assertTrue(Quaterniond.euler_to_quaternion(0.1, 0.2, 0.3) ==
Quaterniond(0.983347, 0.0342708, 0.106021, 0.143572))
# to_axis() method
q.x(0.0)
q.y(0.0)
q.z(0.0)
q.w(0.0)
axis, angle = q.to_axis()
self.assertAlmostEqual(axis, Vector3d(1., 0., 0.), delta=1e-3)
self.assertAlmostEqual(angle, 0., delta=1e-3)
# simple 180 rotation about yaw,
# should result in x and y flipping signs
q = Quaterniond(0, 0, math.pi)
v = Vector3d(1, 2, 3)
r1 = q.rotate_vector(v)
r2 = q.rotate_vector_reverse(v)
self.assertTrue(r1 == Vector3d(-1, -2, 3))
self.assertTrue(r2 == Vector3d(-1, -2, 3))
# simple 90 rotation about yaw, should map x to y, y to -x
# simple -90 rotation about yaw, should map x to -y, y to x
q = Quaterniond(0, 0, 0.5 * math.pi)
v = Vector3d(1, 2, 3)
r1 = q.rotate_vector(v)
r2 = q.rotate_vector_reverse(v)
self.assertTrue(r1 == Vector3d(-2, 1, 3))
self.assertTrue(r2 == Vector3d(2, -1, 3))
self.assertTrue(q.inverse().x_axis() == Vector3d(0, -1, 0))
self.assertTrue(q.inverse().y_axis() == Vector3d(1, 0, 0))
self.assertTrue(q.inverse().z_axis() == Vector3d(0, 0, 1))
# Test RPY fixed-body-frame convention:
# Rotate each unit vector in roll and pitch
q = Quaterniond(math.pi/2.0, math.pi/2.0, 0)
v1 = Vector3d(1, 0, 0)
r1 = q.rotate_vector(v1)
# 90 degrees about x does nothing,
# 90 degrees about y sends point down to -z
self.assertAlmostEqual(r1, Vector3d(0, 0, -1))
v2 = Vector3d(0, 1, 0)
r2 = q.rotate_vector(v2)
# 90 degrees about x sends point to +z
# 90 degrees about y sends point to +x
self.assertAlmostEqual(r2, Vector3d(1, 0, 0))
v3 = Vector3d(0, 0, 1)
r3 = q.rotate_vector(v3)
# 90 degrees about x sends point to -y
# 90 degrees about y does nothing
self.assertAlmostEqual(r3, Vector3d(0, -1, 0))
# now try a harder case (axis[1,2,3], rotation[0.3*pi])
# verified with octave
q.axis(Vector3d(1, 2, 3), 0.3*math.pi)
self.assertTrue(q.inverse().x_axis() ==
Vector3d(0.617229, -0.589769, 0.520770))
self.assertTrue(q.inverse().y_axis() ==
Vector3d(0.707544, 0.705561, -0.039555))
self.assertTrue(q.inverse().z_axis() ==
Vector3d(-0.344106, 0.392882, 0.852780))
# rotate about the axis of rotation should not change axis
v = Vector3d(1, 2, 3)
r1 = q.rotate_vector(v)
r2 = q.rotate_vector_reverse(v)
self.assertTrue(r1 == Vector3d(1, 2, 3))
self.assertTrue(r2 == Vector3d(1, 2, 3))
# rotate unit vectors
v = Vector3d(0, 0, 1)
r1 = q.rotate_vector(v)
r2 = q.rotate_vector_reverse(v)
self.assertTrue(r1 == Vector3d(0.520770, -0.039555, 0.852780))
self.assertTrue(r2 == Vector3d(-0.34411, 0.39288, 0.85278))
v = Vector3d(0, 1, 0)
r1 = q.rotate_vector(v)
r2 = q.rotate_vector_reverse(v)
self.assertTrue(r1 == Vector3d(-0.58977, 0.70556, 0.39288))
self.assertTrue(r2 == Vector3d(0.707544, 0.705561, -0.039555))
v = Vector3d(1, 0, 0)
r1 = q.rotate_vector(v)
r2 = q.rotate_vector_reverse(v)
self.assertTrue(r1 == Vector3d(0.61723, 0.70754, -0.34411))
self.assertTrue(r2 == Vector3d(0.61723, -0.58977, 0.52077))
self.assertTrue(-q == Quaterniond(-0.891007, -0.121334,
-0.242668, -0.364002))
self.assertTrue(Matrix3d(q) == Matrix3d(
0.617229, -0.589769, 0.52077,
0.707544, 0.705561, -0.0395554,
-0.344106, 0.392882, 0.85278))
matFromQ = Matrix3d(q)
self.assertTrue(matFromQ == Matrix3d(
0.617229, -0.589769, 0.52077,
0.707544, 0.705561, -0.0395554,
-0.344106, 0.392882, 0.85278))
# TODO(ahcorde): Enable the corresponding tests when these classes
# are ported
# self.assertTrue(Matrix4d(q) == Matrix4d(
# 0.617229, -0.589769, 0.52077, 0,
# 0.707544, 0.705561, -0.0395554, 0,
# -0.344106, 0.392882, 0.85278, 0,
# 0, 0, 0, 1))
def test_stream_out(self):
q = Quaterniond(0.1, 1.2, 2.3)
self.assertEqual(str(q), "0.1 1.2 2.3")
def test_slerp(self):
q1 = Quaterniond(0.1, 1.2, 2.3)
q2 = Quaterniond(1.2, 2.3, -3.4)
q3 = Quaterniond.slerp(1.0, q1, q2, True)
self.assertAlmostEqual(q3, Quaterniond(0.554528, -0.717339,
0.32579, 0.267925))
def test_from_2_axes(self):
v1 = Vector3d(1.0, 0.0, 0.0)
v2 = Vector3d(0.0, 1.0, 0.0)
q1 = Quaterniond()
q1.from_2_axes(v1, v2)
q2 = Quaterniond()
q2.from_2_axes(v2, v1)
q2Correct = Quaterniond(math.sqrt(2)/2, 0, 0, -math.sqrt(2)/2)
q1Correct = Quaterniond(math.sqrt(2)/2, 0, 0, math.sqrt(2)/2)
self.assertNotEqual(q1, q2)
self.assertAlmostEqual(q1Correct, q1)
self.assertAlmostEqual(q2Correct, q2)
self.assertAlmostEqual(Quaterniond.IDENTITY, q1 * q2)
self.assertAlmostEqual(v2, q1 * v1)
self.assertAlmostEqual(v1, q2 * v2)
# still the same rotation, but with non-unit vectors
v1.set(0.5, 0.5, 0)
v2.set(-0.5, 0.5, 0)
q1.from_2_axes(v1, v2)
q2.from_2_axes(v2, v1)
self.assertNotEqual(q1, q2)
self.assertAlmostEqual(q1Correct, q1)
self.assertAlmostEqual(q2Correct, q2)
self.assertAlmostEqual(Quaterniond.IDENTITY, q1 * q2)
self.assertAlmostEqual(v2, q1 * v1)
self.assertAlmostEqual(v1, q2 * v2)
# Test various settings of opposite vectors (which need special care)
tolerance = 1e-4
v1.set(1, 0, 0)
v2.set(-1, 0, 0)
q1.from_2_axes(v1, v2)
q2 = q1 * q1
self.assertTrue(abs(q2.w()-1.0) <= tolerance or
abs(q2.w()-(-1.0)) <= tolerance)
self.assertAlmostEqual(q2.x(), 0.0)
self.assertAlmostEqual(q2.y(), 0.0)
self.assertAlmostEqual(q2.z(), 0.0)
v1.set(0, 1, 0)
v2.set(0, -1, 0)
q1.from_2_axes(v1, v2)
q2 = q1 * q1
self.assertTrue(abs(q2.w()-1.0) <= tolerance or
abs(q2.w()-(-1.0)) <= tolerance)
self.assertAlmostEqual(q2.x(), 0.0)
self.assertAlmostEqual(q2.y(), 0.0)
self.assertAlmostEqual(q2.z(), 0.0)
v1.set(0, 0, 1)
v2.set(0, 0, -1)
q1.from_2_axes(v1, v2)
q2 = q1 * q1
self.assertTrue(abs(q2.w()-1.0) <= tolerance or
abs(q2.w()-(-1.0)) <= tolerance)
self.assertAlmostEqual(q2.x(), 0.0)
self.assertAlmostEqual(q2.y(), 0.0)
self.assertAlmostEqual(q2.z(), 0.0)
v1.set(0, 1, 1)
v2.set(0, -1, -1)
q1.from_2_axes(v1, v2)
q2 = q1 * q1
self.assertTrue(abs(q2.w()-1.0) <= tolerance or
abs(q2.w()-(-1.0)) <= tolerance)
self.assertAlmostEqual(q2.x(), 0.0)
self.assertAlmostEqual(q2.y(), 0.0)
self.assertAlmostEqual(q2.z(), 0.0)
def test_integrate(self):
# integrate by zero, expect no change
q = Quaterniond(0.5, 0.5, 0.5, 0.5)
self.assertAlmostEqual(q, q.integrate(Vector3d.ZERO, 1.0))
self.assertAlmostEqual(q, q.integrate(Vector3d.UNIT_X, 0.0))
self.assertAlmostEqual(q, q.integrate(Vector3d.UNIT_Y, 0.0))
self.assertAlmostEqual(q, q.integrate(Vector3d.UNIT_Z, 0.0))
# integrate along single axes,
# expect linear change in roll, pitch, yaw
q = Quaterniond(1, 0, 0, 0)
qRoll = q.integrate(Vector3d.UNIT_X, 1.0)
qPitch = q.integrate(Vector3d.UNIT_Y, 1.0)
qYaw = q.integrate(Vector3d.UNIT_Z, 1.0)
self.assertAlmostEqual(qRoll.euler(), Vector3d.UNIT_X)
self.assertAlmostEqual(qPitch.euler(), Vector3d.UNIT_Y)
self.assertAlmostEqual(qYaw.euler(), Vector3d.UNIT_Z)
# integrate sequentially along single axes in order XYZ,
# expect rotations to match euler Angles
q = Quaterniond(1, 0, 0, 0)
angle = 0.5
qX = q.integrate(Vector3d.UNIT_X, angle)
qXY = qX.integrate(Vector3d.UNIT_Y, angle)
self.assertAlmostEqual(qXY.euler(), Vector3d(1, 1, 0)*angle)
q = Quaterniond(1, 0, 0, 0)
angle = 0.5
qX = q.integrate(Vector3d.UNIT_X, angle)
qXZ = qX.integrate(Vector3d.UNIT_Z, angle)
self.assertAlmostEqual(qXZ.euler(), Vector3d(1, 0, 1)*angle)
q = Quaterniond(1, 0, 0, 0)
angle = 0.5
qY = q.integrate(Vector3d.UNIT_Y, angle)
qYZ = qY.integrate(Vector3d.UNIT_Z, angle)
self.assertAlmostEqual(qYZ.euler(), Vector3d(0, 1, 1)*angle)
q = Quaterniond(1, 0, 0, 0)
angle = 0.5
qX = q.integrate(Vector3d.UNIT_X, angle)
qXY = qX.integrate(Vector3d.UNIT_Y, angle)
qXYZ = qXY.integrate(Vector3d.UNIT_Z, angle)
self.assertAlmostEqual(qXYZ.euler(), Vector3d.ONE*angle)
# integrate sequentially along single axes in order ZYX,
# expect rotations to not match euler Angles
q = Quaterniond(1, 0, 0, 0)
angle = 0.5
qZ = q.integrate(Vector3d.UNIT_Z, angle)
qZY = qZ.integrate(Vector3d.UNIT_Y, angle)
self.assertNotEqual(qZY.euler(), Vector3d(0, 1, 1)*angle)
q = Quaterniond(1, 0, 0, 0)
angle = 0.5
qZ = q.integrate(Vector3d.UNIT_Z, angle)
qZX = qZ.integrate(Vector3d.UNIT_X, angle)
self.assertNotEqual(qZX.euler(), Vector3d(1, 0, 1)*angle)
q = Quaterniond(1, 0, 0, 0)
angle = 0.5
qZ = q.integrate(Vector3d.UNIT_Z, angle)
qZY = qZ.integrate(Vector3d.UNIT_Y, angle)
qZYX = qZY.integrate(Vector3d.UNIT_X, angle)
self.assertNotEqual(qZYX.euler(), Vector3d(1, 1, 1)*angle)
q = Quaterniond(1, 0, 0, 0)
angle = 0.5
qY = q.integrate(Vector3d.UNIT_Y, angle)
qYX = qY.integrate(Vector3d.UNIT_X, angle)
self.assertNotEqual(qYX.euler(), Vector3d(1, 1, 0)*angle)
# integrate a full rotation about different axes,
# expect no change.
q = Quaterniond(0.5, 0.5, 0.5, 0.5)
fourPi = 4 * math.pi
qX = q.integrate(Vector3d.UNIT_X, fourPi)
qY = q.integrate(Vector3d.UNIT_Y, fourPi)
qZ = q.integrate(Vector3d.UNIT_Z, fourPi)
self.assertAlmostEqual(q, qX)
self.assertAlmostEqual(q, qY)
self.assertAlmostEqual(q, qZ)
if __name__ == '__main__':
unittest.main()