Skip to content

Commit de27642

Browse files
authored
feat: orient quads
feat: orient quads
2 parents a6cda45 + 2fe5d3e commit de27642

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "twirl"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
description = "Astrometric plate solving in Python"
55
authors = ["Lionel J. Garcia <lionel_garcia@live.fr>"]
66
maintainers = [

‎twirl/quads.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def good_quads(quads, circletol=0.01):
2929
return np.all(in_circle, axis=1)
3030

3131

32-
def quad_hash(quads):
32+
def quad_hash(quads, oriented=True):
3333
a, b, c, d = np.rollaxis(quads, 1)
3434

3535
norm = np.linalg.norm(b - a, axis=1)
@@ -48,6 +48,11 @@ def u1u2(a, b):
4848

4949
u1, u2 = u1u2(a, b)
5050

51+
if oriented:
52+
reverse = (np.cross((b - a), (b - c))) >= 0
53+
# invert u1 and u2 for reversed quads
54+
u1[reverse], u2[reverse] = u2[reverse], u1[reverse]
55+
5156
def proj(p, origin, axe):
5257
"""projection of a point p on a segment from origin to axe"""
5358
n = axe - origin

0 commit comments

Comments
 (0)