Package test_suite :: Package unit_tests :: Package _lib :: Package _geometry :: Module test_vectors
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._lib._geometry.test_vectors

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2014 Edward d'Auvergne                                        # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Python module imports. 
 23  from math import pi 
 24  from numpy import array, float64 
 25  from unittest import TestCase 
 26   
 27  # relax module imports. 
 28  from lib.geometry.vectors import vector_angle_acos, vector_angle_atan2, vector_angle_normal 
 29   
 30   
31 -class Test_vectors(TestCase):
32 """Unit tests for the lib.geometry.vectors relax module.""" 33
34 - def test_vector_angle_acos_1(self):
35 """Test the vector_angle_acos() function with the vectors [1, 0, 0] and [0, 1, 0].""" 36 37 # Calculate the angle. 38 v1 = array([1, 0, 0], float64) 39 v2 = array([0, 1, 0], float64) 40 angle = vector_angle_acos(v1, v2) 41 42 # Check the angle. 43 self.assertAlmostEqual(angle, pi/2.0)
44 45
46 - def test_vector_angle_acos_2(self):
47 """Test the vector_angle_acos() function with the vectors [1, 0, 0] and [0, 2, 0].""" 48 49 # Calculate the angle. 50 v1 = array([1, 0, 0], float64) 51 v2 = array([0, 2, 0], float64) 52 angle = vector_angle_acos(v1, v2) 53 54 # Check the angle. 55 self.assertAlmostEqual(angle, pi/2.0)
56 57
58 - def test_vector_angle_acos_3(self):
59 """Test the vector_angle_acos() function with the vectors [2, 0, 0] and [0, -2, 0].""" 60 61 # Calculate the angle. 62 v1 = array([2, 0, 0], float64) 63 v2 = array([0, -2, 0], float64) 64 angle = vector_angle_acos(v1, v2) 65 66 # Check the angle. 67 self.assertAlmostEqual(angle, pi/2.0)
68 69
70 - def test_vector_angle_acos_4(self):
71 """Test the vector_angle_acos() function with the vectors [2, 0, 0] and [2, 2, 0].""" 72 73 # Calculate the angle. 74 v1 = array([2, 0, 0], float64) 75 v2 = array([2, 2, 0], float64) 76 angle = vector_angle_acos(v1, v2) 77 78 # Check the angle. 79 self.assertAlmostEqual(angle, pi/4.0)
80 81
82 - def test_vector_angle_acos_5(self):
83 """Test the vector_angle_acos() function with the vectors [2, 0, 0] and [2, 2, 0].""" 84 85 # Calculate the angle. 86 v1 = array([2, 0, 0], float64) 87 v2 = array([2, 2, 0], float64) 88 angle = vector_angle_acos(v1, v2) 89 90 # Check the angle. 91 self.assertAlmostEqual(angle, pi/4.0)
92 93
94 - def test_vector_angle_acos_6(self):
95 """Test the vector_angle_acos() function with the vectors [2, 2, 0] and [2, -2, 0].""" 96 97 # Calculate the angle. 98 v1 = array([2, 2, 0], float64) 99 v2 = array([2, -2, 0], float64) 100 angle = vector_angle_acos(v1, v2) 101 102 # Check the angle. 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 # Calculate the angle. 110 v1 = array([1, 0, 0], float64) 111 v2 = array([0, 1, 0], float64) 112 angle = vector_angle_atan2(v1, v2) 113 114 # Check the angle. 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 # Calculate the angle. 122 v1 = array([1, 0, 0], float64) 123 v2 = array([0, 2, 0], float64) 124 angle = vector_angle_atan2(v1, v2) 125 126 # Check the angle. 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 # Calculate the angle. 134 v1 = array([2, 0, 0], float64) 135 v2 = array([0, -2, 0], float64) 136 angle = vector_angle_atan2(v1, v2) 137 138 # Check the angle. 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 # Calculate the angle. 146 v1 = array([2, 0, 0], float64) 147 v2 = array([2, 2, 0], float64) 148 angle = vector_angle_atan2(v1, v2) 149 150 # Check the angle. 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 # Calculate the angle. 158 v1 = array([2, 0, 0], float64) 159 v2 = array([2, 2, 0], float64) 160 angle = vector_angle_atan2(v1, v2) 161 162 # Check the angle. 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 # Calculate the angle. 170 v1 = array([2, 2, 0], float64) 171 v2 = array([2, -2, 0], float64) 172 angle = vector_angle_atan2(v1, v2) 173 174 # Check the angle. 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 # Calculate the angle. 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 # Check the angle. 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 # Calculate the angle. 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 # Check the angle. 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 # Calculate the angle. 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 # Check the angle. 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 # Calculate the angle. 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 # Check the angle. 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 # Calculate the angle. 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 # Check the angle. 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 # Calculate the angle. 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 # Check the angle. 253 self.assertAlmostEqual(angle, -pi/2.0)
254