Skip to content

Commit

Permalink
added collinearity test to library
Browse files Browse the repository at this point in the history
  • Loading branch information
jtauber committed Jan 29, 2013
1 parent 92809ba commit f1d18d0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions folds.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ def quadrance(vertex_1, vertex_2):
zip(vertex_1.coordinates, vertex_2.coordinates))


def collinear(vertex_1, vertex_2, vertex_3):
q12 = quadrance(vertex_1, vertex_2)
q13 = quadrance(vertex_1, vertex_3)
q23 = quadrance(vertex_2, vertex_3)

cayley_mengler_det = (
q12 * q12 + q13 * q13 + q23 * q23
- 2 * q12 * q13 - 2 * q12 * q23 - 2 * q13 * q23
)

return cayley_mengler_det == 0


class Edge:
def __init__(self, vertex_1, vertex_2):
self.vertex_1 = vertex_1
Expand Down

0 comments on commit f1d18d0

Please sign in to comment.