From 1741906516f43296586f686dc13b55353433fdbc Mon Sep 17 00:00:00 2001 From: Stefan Witzel Date: Thu, 10 Aug 2023 12:14:42 +0200 Subject: [PATCH 1/2] Transform.apply_to_list for inhomogeneous lists --- hyperbolic/poincare/transform.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hyperbolic/poincare/transform.py b/hyperbolic/poincare/transform.py index e44c5f8..b099329 100644 --- a/hyperbolic/poincare/transform.py +++ b/hyperbolic/poincare/transform.py @@ -35,17 +35,17 @@ def apply_to_ideal(self, point, verify=False): raise ValueError('Invalid transform') return Ideal(math.atan2(y, x)) def apply_to_list(self, points, verify=False): - if len(points) > 0: - if isinstance(points[0], Ideal): + def apply(pt): + if isinstance(pt, Ideal): if verify: - def f(p): return self.apply_to_ideal(p, verify=True) + return self.apply_to_ideal(pt, verify=True) else: - f = self.apply_to_ideal - elif isinstance(points[0], Point): - f = self.apply_to_point + return self.apply_to_ideal(pt) + elif isinstance(pt, Point): + return self.apply_to_point(pt) else: - f = self.apply_to_tuple - return [f(p) for p in points] + return self.apply_to_tuple(pt) + return [apply(p) for p in points] def apply_to_shape(self, shape): '''Transform a euclidean shape. From 4a6715f7fea7aff15c960a19ebb61463e90f0eb9 Mon Sep 17 00:00:00 2001 From: Stefan Witzel Date: Thu, 10 Aug 2023 13:42:41 +0200 Subject: [PATCH 2/2] Horocycle.from_center_point() --- hyperbolic/poincare/horocycle.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hyperbolic/poincare/horocycle.py b/hyperbolic/poincare/horocycle.py index 9d2d4ad..a2fb25f 100644 --- a/hyperbolic/poincare/horocycle.py +++ b/hyperbolic/poincare/horocycle.py @@ -4,6 +4,7 @@ from ..euclid import Circle as ECircle from .util import radial_euclid_to_poincare, radial_poincare_to_euclid from . import point +from .transform import Transform class Horocycle: @@ -39,6 +40,13 @@ def from_closest_point(pt, surround_origin=False, cw=True): return Horocycle( shape, closest_point=pt, surround_origin=surround_origin) @classmethod + def from_center_point(cls,center,pt,cw = True): + theta = math.atan2(center.y,center.x) + rot = Transform.rotation(rad=-theta) + rpt = rot.apply_to_point(pt) + d = (rpt.x**2 + rpt.y**2 - rpt.x)/(rpt.x - 1) + return cls.from_closest_point_e_polar(d,theta,cw = cw) + @classmethod def from_closest_point_h_polar(cls, hr, theta, cw=True): p = point.Point.from_h_polar(hr, theta) return cls.from_closest_point(p, surround_origin=hr<0, cw=cw)