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
29
30
32 """Unit tests for the lib.geometry.vectors relax module."""
33
35 """Test the vector_angle() 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 normal = array([0, 0, 1], float64)
41 angle = vector_angle(v1, v2, normal)
42
43
44 self.assertAlmostEqual(angle, pi/2.0)
45
46
48 """Test the vector_angle() function with the vectors [1, 0, 0] and [0, 2, 0]."""
49
50
51 v1 = array([1, 0, 0], float64)
52 v2 = array([0, 2, 0], float64)
53 normal = array([0, 0, 1], float64)
54 angle = vector_angle(v1, v2, normal)
55
56
57 self.assertAlmostEqual(angle, pi/2.0)
58
59
61 """Test the vector_angle() function with the vectors [2, 0, 0] and [0, -2, 0]."""
62
63
64 v1 = array([2, 0, 0], float64)
65 v2 = array([0, -2, 0], float64)
66 normal = array([0, 0, 1], float64)
67 angle = vector_angle(v1, v2, normal)
68
69
70 self.assertAlmostEqual(angle, -pi/2.0)
71
72
74 """Test the vector_angle() function with the vectors [2, 0, 0] and [2, 2, 0]."""
75
76
77 v1 = array([2, 0, 0], float64)
78 v2 = array([2, 2, 0], float64)
79 normal = array([0, 0, 2], float64)
80 angle = vector_angle(v1, v2, normal)
81
82
83 self.assertAlmostEqual(angle, pi/4.0)
84
85
87 """Test the vector_angle() function with the vectors [2, 0, 0] and [2, 2, 0]."""
88
89
90 v1 = array([2, 0, 0], float64)
91 v2 = array([2, 2, 0], float64)
92 normal = array([0, 0, -2], float64)
93 angle = vector_angle(v1, v2, normal)
94
95
96 self.assertAlmostEqual(angle, -pi/4.0)
97
98
100 """Test the vector_angle() function with the vectors [2, 2, 0] and [2, -2, 0]."""
101
102
103 v1 = array([2, 2, 0], float64)
104 v2 = array([2, -2, 0], float64)
105 normal = array([0, 0, 2], float64)
106 angle = vector_angle(v1, v2, normal)
107
108
109 self.assertAlmostEqual(angle, -pi/2.0)
110