1 from __future__
import print_function
18 if issubclass(a.__class__, np.ndarray)
and issubclass(b.__class__, np.ndarray):
19 return np.allclose(a, b, epsilon)
21 return abs(a - b) < epsilon
26 verbose
and print(
"[Quaternion] Coefficient initialisation")
27 q = Quaternion(1, 2, 3, 4)
29 assert isapprox(np.linalg.norm(q.coeffs()), q.norm())
30 assert isapprox(np.linalg.norm(q.coeffs()), 1)
33 verbose
and print(
"[Quaternion] Coefficient-vector initialisation")
34 v = np.array([0.5, -0.5, 0.5, 0.5])
35 for k
in range(10000):
40 verbose
and print(
"[Quaternion] AngleAxis initialisation")
44 assert isapprox(q.coeffs(), q2.coeffs())
45 assert q2.isApprox(q2)
46 assert q2.isApprox(q2, 1e-2)
50 assert isapprox(Rq.dot(Rq.T), np.eye(3))
54 verbose
and print(
"[Quaternion] Rotation Matrix initialisation")
57 assert isapprox(q.coeffs(), qR.coeffs())
59 assert isapprox(qR[3], 1.0 / np.sqrt(30))
62 print(
"Error, this message should not appear.")
63 except RuntimeError
as e:
65 print(
"As expected, caught exception: ", e)
68 r = AngleAxis(0.1, np.array([1, 0, 0], np.double))
70 print(
"Rx(.1) = \n\n", r.matrix(),
"\n")
71 assert isapprox(r.matrix()[2, 2], cos(r.angle))
72 assert isapprox(r.axis, np.array([1.0, 0, 0]))
75 assert r.isApprox(r, 1e-2)
77 r.axis = np.array([0, 1, 0], np.double).T
78 assert isapprox(r.matrix()[0, 0], cos(r.angle))
84 r2 = AngleAxis(np.dot(R, R))
85 assert isapprox(r2.angle, r.angle * 2)
89 assert ro.__class__ == AngleAxis
94 assert qo.__class__ == Quaternion
96 assert q.norm() == res
Eigen::AngleAxisd testOutAngleAxis()
def isapprox(a, b, epsilon=1e-6)
Eigen::Quaterniond testOutQuaternion()
double testInAngleAxis(Eigen::AngleAxisd aa)
double testInQuaternion(Eigen::Quaterniond q)
void print(const Tensor &tensor)