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 
 29   
 30   
31 -class Test_vectors(TestCase):
32 """Unit tests for the lib.geometry.vectors relax module.""" 33
34 - def test_vector_angle1(self):
35 """Test the vector_angle() 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 normal = array([0, 0, 1], float64) 41 angle = vector_angle(v1, v2, normal) 42 43 # Check the angle. 44 self.assertAlmostEqual(angle, pi/2.0)
45 46
47 - def test_vector_angle2(self):
48 """Test the vector_angle() function with the vectors [1, 0, 0] and [0, 2, 0].""" 49 50 # Calculate the angle. 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 # Check the angle. 57 self.assertAlmostEqual(angle, pi/2.0)
58 59
60 - def test_vector_angle3(self):
61 """Test the vector_angle() function with the vectors [2, 0, 0] and [0, -2, 0].""" 62 63 # Calculate the angle. 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 # Check the angle. 70 self.assertAlmostEqual(angle, -pi/2.0)
71 72
73 - def test_vector_angle4(self):
74 """Test the vector_angle() function with the vectors [2, 0, 0] and [2, 2, 0].""" 75 76 # Calculate the angle. 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 # Check the angle. 83 self.assertAlmostEqual(angle, pi/4.0)
84 85
86 - def test_vector_angle5(self):
87 """Test the vector_angle() function with the vectors [2, 0, 0] and [2, 2, 0].""" 88 89 # Calculate the angle. 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 # Check the angle. 96 self.assertAlmostEqual(angle, -pi/4.0)
97 98
99 - def test_vector_angle6(self):
100 """Test the vector_angle() function with the vectors [2, 2, 0] and [2, -2, 0].""" 101 102 # Calculate the angle. 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 # Check the angle. 109 self.assertAlmostEqual(angle, -pi/2.0)
110