forked from centreborelli/s2p
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevaluation_test.py
31 lines (26 loc) · 1.15 KB
/
evaluation_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright (C) 2015, Carlo de Franchis <[email protected]>
# Copyright (C) 2015, Gabriele Facciolo <[email protected]>
# Copyright (C) 2015, Enric Meinhardt <[email protected]>
# Copyright (C) 2015, Julien Michel <[email protected]>
import numpy as np
import s2p
def test_finite_distances():
x = np.array([1, 1, 1])
l = np.array([0, 1, 0])
np.testing.assert_equal(s2p.evaluation.distance_point_to_line(x, l), 1)
x = np.array([-1, -1, -1])
l = np.array([0, 1, 0])
np.testing.assert_equal(s2p.evaluation.distance_point_to_line(x, l), 1)
x = np.array([1, 1, 1])
l = np.array([3, 2, -1])
np.testing.assert_equal(s2p.evaluation.distance_point_to_line(x, l),
4 / np.sqrt(13))
def test_infinite_distances():
x = np.array([1, 1, 0])
l = np.array([0, 1, 0])
np.testing.assert_equal(s2p.evaluation.distance_point_to_line(x, l),
np.finfo(float).max)
x = np.array([1, 1, -7])
l = np.array([0, 0, 2.3])
np.testing.assert_equal(s2p.evaluation.distance_point_to_line(x, l),
np.finfo(float).max)