1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from math import pi
24 from numpy import array, float64
25 from unittest import TestCase
26
27
28 from lib.geometry.vectors import vector_angle_acos, vector_angle_atan2, vector_angle_normal
29
30
32 """Unit tests for the lib.geometry.vectors relax module."""
33
35 """Test the vector_angle_acos() function with the vectors [1, 0, 0] and [0, 1, 0]."""
36
37
38 v1 = array([1, 0, 0], float64)
39 v2 = array([0, 1, 0], float64)
40 angle = vector_angle_acos(v1, v2)
41
42
43 self.assertAlmostEqual(angle, pi/2.0)
44
45
47 """Test the vector_angle_acos() function with the vectors [1, 0, 0] and [0, 2, 0]."""
48
49
50 v1 = array([1, 0, 0], float64)
51 v2 = array([0, 2, 0], float64)
52 angle = vector_angle_acos(v1, v2)
53
54
55 self.assertAlmostEqual(angle, pi/2.0)
56
57
59 """Test the vector_angle_acos() function with the vectors [2, 0, 0] and [0, -2, 0]."""
60
61
62 v1 = array([2, 0, 0], float64)
63 v2 = array([0, -2, 0], float64)
64 angle = vector_angle_acos(v1, v2)
65
66
67 self.assertAlmostEqual(angle, pi/2.0)
68
69
71 """Test the vector_angle_acos() function with the vectors [2, 0, 0] and [2, 2, 0]."""
72
73
74 v1 = array([2, 0, 0], float64)
75 v2 = array([2, 2, 0], float64)
76 angle = vector_angle_acos(v1, v2)
77
78
79 self.assertAlmostEqual(angle, pi/4.0)
80
81
83 """Test the vector_angle_acos() function with the vectors [2, 0, 0] and [2, 2, 0]."""
84
85
86 v1 = array([2, 0, 0], float64)
87 v2 = array([2, 2, 0], float64)
88 angle = vector_angle_acos(v1, v2)
89
90
91 self.assertAlmostEqual(angle, pi/4.0)
92
93
95 """Test the vector_angle_acos() function with the vectors [2, 2, 0] and [2, -2, 0]."""
96
97
98 v1 = array([2, 2, 0], float64)
99 v2 = array([2, -2, 0], float64)
100 angle = vector_angle_acos(v1, v2)
101
102
103 self.assertAlmostEqual(angle, pi/2.0)
104
105
107 """Test the vector_angle_atan2() function with the vectors [1, 0, 0] and [0, 1, 0]."""
108
109
110 v1 = array([1, 0, 0], float64)
111 v2 = array([0, 1, 0], float64)
112 angle = vector_angle_atan2(v1, v2)
113
114
115 self.assertAlmostEqual(angle, pi/2.0)
116
117
119 """Test the vector_angle_atan2() function with the vectors [1, 0, 0] and [0, 2, 0]."""
120
121
122 v1 = array([1, 0, 0], float64)
123 v2 = array([0, 2, 0], float64)
124 angle = vector_angle_atan2(v1, v2)
125
126
127 self.assertAlmostEqual(angle, pi/2.0)
128
129
131 """Test the vector_angle_atan2() function with the vectors [2, 0, 0] and [0, -2, 0]."""
132
133
134 v1 = array([2, 0, 0], float64)
135 v2 = array([0, -2, 0], float64)
136 angle = vector_angle_atan2(v1, v2)
137
138
139 self.assertAlmostEqual(angle, pi/2.0)
140
141
143 """Test the vector_angle_atan2() function with the vectors [2, 0, 0] and [2, 2, 0]."""
144
145
146 v1 = array([2, 0, 0], float64)
147 v2 = array([2, 2, 0], float64)
148 angle = vector_angle_atan2(v1, v2)
149
150
151 self.assertAlmostEqual(angle, pi/4.0)
152
153
155 """Test the vector_angle_atan2() function with the vectors [2, 0, 0] and [2, 2, 0]."""
156
157
158 v1 = array([2, 0, 0], float64)
159 v2 = array([2, 2, 0], float64)
160 angle = vector_angle_atan2(v1, v2)
161
162
163 self.assertAlmostEqual(angle, pi/4.0)
164
165
167 """Test the vector_angle_atan2() function with the vectors [2, 2, 0] and [2, -2, 0]."""
168
169
170 v1 = array([2, 2, 0], float64)
171 v2 = array([2, -2, 0], float64)
172 angle = vector_angle_atan2(v1, v2)
173
174
175 self.assertAlmostEqual(angle, pi/2.0)
176
177
179 """Test the vector_angle_normal() function with the vectors [1, 0, 0] and [0, 1, 0]."""
180
181
182 v1 = array([1, 0, 0], float64)
183 v2 = array([0, 1, 0], float64)
184 normal = array([0, 0, 1], float64)
185 angle = vector_angle_normal(v1, v2, normal)
186
187
188 self.assertAlmostEqual(angle, pi/2.0)
189
190
192 """Test the vector_angle_normal() function with the vectors [1, 0, 0] and [0, 2, 0]."""
193
194
195 v1 = array([1, 0, 0], float64)
196 v2 = array([0, 2, 0], float64)
197 normal = array([0, 0, 1], float64)
198 angle = vector_angle_normal(v1, v2, normal)
199
200
201 self.assertAlmostEqual(angle, pi/2.0)
202
203
205 """Test the vector_angle_normal() function with the vectors [2, 0, 0] and [0, -2, 0]."""
206
207
208 v1 = array([2, 0, 0], float64)
209 v2 = array([0, -2, 0], float64)
210 normal = array([0, 0, 1], float64)
211 angle = vector_angle_normal(v1, v2, normal)
212
213
214 self.assertAlmostEqual(angle, -pi/2.0)
215
216
218 """Test the vector_angle_normal() function with the vectors [2, 0, 0] and [2, 2, 0]."""
219
220
221 v1 = array([2, 0, 0], float64)
222 v2 = array([2, 2, 0], float64)
223 normal = array([0, 0, 2], float64)
224 angle = vector_angle_normal(v1, v2, normal)
225
226
227 self.assertAlmostEqual(angle, pi/4.0)
228
229
231 """Test the vector_angle_normal() function with the vectors [2, 0, 0] and [2, 2, 0]."""
232
233
234 v1 = array([2, 0, 0], float64)
235 v2 = array([2, 2, 0], float64)
236 normal = array([0, 0, -2], float64)
237 angle = vector_angle_normal(v1, v2, normal)
238
239
240 self.assertAlmostEqual(angle, -pi/4.0)
241
242
244 """Test the vector_angle_normal() function with the vectors [2, 2, 0] and [2, -2, 0]."""
245
246
247 v1 = array([2, 2, 0], float64)
248 v2 = array([2, -2, 0], float64)
249 normal = array([0, 0, 2], float64)
250 angle = vector_angle_normal(v1, v2, normal)
251
252
253 self.assertAlmostEqual(angle, -pi/2.0)
254