-
Notifications
You must be signed in to change notification settings - Fork 13
/
test_qnv.py
99 lines (79 loc) · 1.87 KB
/
test_qnv.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
import numpy as np
import qnv
A=np.array([1,2,3])
B=np.array([-1,-2,-3])
C=np.array([1,-2,-3])
D=np.array([4,-6,7])
E=np.array([0,-3,2])
F=np.array([0,0,0])
q1=np.array([1,2,3,4])
q2=np.array([1,-2,-3,-4])
q3=np.array([1,-2,-3,4])
q4=np.array([1,2,3,-4])
q5=np.array([-1,-2,-3,4])
q6=np.array([-1,2,3,-4])
q7=np.array([0,2,-3,0])
q8=np.array([0,-2,3,0])
q9=np.array([0,0,0,0])
flag=1 # tessting for quatInv
G=qnv.quatInv(q1)
if (G == q2).all() == 0:
flag=0
G=qnv.quatInv(q3)
if (G == q4).all() == 0:
flag=0
G=qnv.quatInv(q5)
if (G == q6).all() == 0:
flag=0
G=qnv.quatInv(q7)
if (G == q8).all() == 0:
flag=0
G=qnv.quatInv(q9)
if (G == q9).all() == 0:
flag=0
if flag == 1:
print ("all cases passed for quatInv")
else:
print ("error for quatInv")
flag=1 # testing for quatMultiplynorm
m1 = np.array([1,-1,-1,1])
m2 = np.array([-1,1,-1,-1])
m3 = np.array([0,1,1,-1])
m4 = np.array([0,1,-1,0])
m5 = np.array([0,0,-1,1])
m6 = np.array([0,4,0,0])
m7 = np.array([-1,-3,-1,-1])
m8 = np.array([-1,-1,-1,-1])
m9 = m6/np.linalg.norm(m6)
m10 = m7/np.linalg.norm(m7)
m11 = m8/np.linalg.norm(m8)
G=qnv.quatMultiplyNorm(m1,m2)
if (G == m9).all() == 0:
flag=0
G=qnv.quatMultiplyNorm(m3,m2)
if (G == m10).all() == 0:
flag=0
G=qnv.quatMultiplyNorm(m4,m5)
if (G == m11).all() == 0:
flag=0
if flag == 1:
print ("all cases passed for quatMultiplynorm")
else:
print ("error for quatMultiplynorm")
flag=1 # testing for quatMultiplynorm
G=qnv.quatMultiplyUnnorm(m1,m2)
if (G == m6).all() == 0:
flag=0
G=qnv.quatMultiplyUnnorm(m3,m2)
if (G == m7).all() == 0:
flag=0
G=qnv.quatMultiplyUnnorm(m4,m5)
if (G == m8).all() == 0:
flag=0
G=qnv.quatMultiplyUnnorm(q9,q9)
if (G == q9).all() == 0:
flag=0
if flag == 1:
print ("all cases passed for quatMultiplyUnnorm")
else:
print ("error for quatMultiplyUnnorm")