Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform.apply_to_list for inhomogeneous lists #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions hyperbolic/poincare/horocycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave a space between two methods

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave a space between two methods

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)
Expand Down
16 changes: 8 additions & 8 deletions hyperbolic/poincare/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down