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

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

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2013 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 numpy import array, float64 
24  from unittest import TestCase 
25   
26  # relax module imports. 
27  from lib.geometry.lines import closest_point, closest_point_ax 
28   
29   
30 -class Test_lines(TestCase):
31 """Unit tests for the lib.geometry.lines relax module.""" 32
33 - def test_closest_point(self):
34 """Test the closest_point() function.""" 35 36 # Get and check the point. 37 pt = closest_point(line_pt1=array([1, 1, 0], float64), line_pt2=array([-1, -1, 0], float64), point=array([0, 0, 10])) 38 self.assertEqual(pt[0], 0.0) 39 self.assertEqual(pt[1], 0.0) 40 self.assertEqual(pt[2], 0.0)
41 42
43 - def test_closest_point_ax1(self):
44 """Test the closest_point_ax() function.""" 45 46 # Get and check the point. 47 pt = closest_point_ax(line_pt=array([1, 1, 0], float64), axis=array([1, 1, 0], float64), point=array([0, 0, 10], float64)) 48 self.assertAlmostEqual(pt[0], 0.0) 49 self.assertAlmostEqual(pt[1], 0.0) 50 self.assertAlmostEqual(pt[2], 0.0)
51 52
53 - def test_closest_point_ax2(self):
54 """Test the closest_point_ax() function.""" 55 56 # Get and check the point. 57 pt = closest_point_ax(line_pt=array([2, 2, 2], float64), axis=array([1, 1, 1], float64), point=array([0, 0, 0], float64)) 58 self.assertAlmostEqual(pt[0], 0.0) 59 self.assertAlmostEqual(pt[1], 0.0) 60 self.assertAlmostEqual(pt[2], 0.0)
61 62
63 - def test_closest_point_ax3(self):
64 """Test the closest_point_ax() function.""" 65 66 # Get and check the point. 67 pt = closest_point_ax(line_pt=array([-2, -2, -2], float64), axis=array([1, 1, 1], float64), point=array([1, -1, 0], float64)) 68 self.assertAlmostEqual(pt[0], 0.0) 69 self.assertAlmostEqual(pt[1], 0.0) 70 self.assertAlmostEqual(pt[2], 0.0)
71 72
73 - def test_closest_point_ax4(self):
74 """Test the closest_point_ax() function.""" 75 76 # Get and check the point. 77 pt = closest_point_ax(line_pt=array([-2, -2, 0], float64), axis=array([1, 1, 1], float64), point=array([1, -1, 2], float64)) 78 self.assertAlmostEqual(pt[0], 0.0) 79 self.assertAlmostEqual(pt[1], 0.0) 80 self.assertAlmostEqual(pt[2], 2.0)
81