Skip to content

Commit

Permalink
A simple quadrilateral will have at least three of the same sign cros…
Browse files Browse the repository at this point in the history
…s products
  • Loading branch information
cjekel committed Dec 21, 2019
1 parent 81c56dd commit bbb8693
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion similaritymeasures/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.1
0.4.2
4 changes: 1 addition & 3 deletions similaritymeasures/similaritymeasures.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ def is_simple_quad(ab, bc, cd, da):
# Because they don't necessarily need to lie in the same 'Z' direction
if sum(crossTF) <= 1:
crossTF = cross <= 0
if sum(crossTF) == 2:
return True
elif sum(crossTF) == 4:
if sum(crossTF) > 2:
return True
else:
return False
Expand Down
22 changes: 17 additions & 5 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,25 @@ def test_P_Q_dtw_minkowski_p3(self):
self.assertTrue(r, 3.0)

def test_complex_quad(self):
a = [0., 0.]
b = [1., 1.]
c = [1., 0.]
d = [0., 1.]
quad = similaritymeasures.is_simple_quad(a, b, d, c)
x = [0, 1, 1, 0]
y = [0, 1, 0, 1]
AB = [x[1]-x[0], y[1]-y[0]]
BC = [x[2]-x[1], y[2]-y[1]]
CD = [x[3]-x[2], y[3]-y[2]]
DA = [x[0]-x[3], y[0]-y[3]]
quad = similaritymeasures.is_simple_quad(AB, BC, CD, DA)
self.assertFalse(quad)

def test_simple_quad(self):
x = [0, 0, 1, 1]
y = [0, 1, 1, 0]
AB = [x[1]-x[0], y[1]-y[0]]
BC = [x[2]-x[1], y[2]-y[1]]
CD = [x[3]-x[2], y[3]-y[2]]
DA = [x[0]-x[3], y[0]-y[3]]
quad = similaritymeasures.is_simple_quad(AB, BC, CD, DA)
self.assertTrue(quad)

def test_random_dtw(self):
r, d = similaritymeasures.dtw(curve_a_rand, curve_b_rand)
path = similaritymeasures.dtw_path(d)
Expand Down

0 comments on commit bbb8693

Please sign in to comment.