def _dist_geod_point(self, start, end, p): r""" Return the hyperbolic distance from a given hyperbolic geodesic and a hyperbolic point. INPUT: - ``start`` -- the start ideal point coordinates of the geodesic - ``end`` -- the end ideal point coordinates of the geodesic - ``p`` -- the coordinates of the point OUTPUT: - the hyperbolic distance EXAMPLES:: sage: UHP = HyperbolicPlane().UHP() sage: UHP._dist_geod_point(2, infinity, I) arccosh(1/10*sqrt(5)*((sqrt(5) - 1)^2 + 4) + 1) If `p` is a boundary point, the distance is infinity:: sage: HyperbolicPlane().UHP()._dist_geod_point(2, infinity, 5) +Infinity """ # Here is the trick for computing distance to a geodesic: # find an isometry mapping the geodesic to the geodesic between # 0 and infinity (so corresponding to the line imag(z) = 0. # then any complex number is r exp(i*theta) in polar coordinates. # the mutual perpendicular between this point and imag(z) = 0 # intersects imag(z) = 0 at ri. So we calculate the distance # between r exp(i*theta) and ri after we transform the original # point. if start + end != infinity: # Not a straight line: # Map the endpoints to 0 and infinity and the midpoint to 1. T = HyperbolicGeodesicUHP._crossratio_matrix( start, (start + end) / 2, end) else: # Is a straight line: # Map the endpoints to 0 and infinity and another endpoint to 1. T = HyperbolicGeodesicUHP._crossratio_matrix(start, start + 1, end) x = moebius_transform(T, p) return self._dist_points(x, abs(x) * I)
def _dist_geod_point(self, start, end, p): r""" Return the hyperbolic distance from a given hyperbolic geodesic and a hyperbolic point. INPUT: - ``start`` -- the start ideal point coordinates of the geodesic - ``end`` -- the end ideal point coordinates of the geodesic - ``p`` -- the coordinates of the point OUTPUT: - the hyperbolic distance EXAMPLES:: sage: UHP = HyperbolicPlane().UHP() sage: UHP._dist_geod_point(2, infinity, I) arccosh(1/10*sqrt(5)*((sqrt(5) - 1)^2 + 4) + 1) If `p` is a boundary point, the distance is infinity:: sage: HyperbolicPlane().UHP()._dist_geod_point(2, infinity, 5) +Infinity """ # Here is the trick for computing distance to a geodesic: # find an isometry mapping the geodesic to the geodesic between # 0 and infinity (so corresponding to the line imag(z) = 0. # then any complex number is r exp(i*theta) in polar coordinates. # the mutual perpendicular between this point and imag(z) = 0 # intersects imag(z) = 0 at ri. So we calculate the distance # between r exp(i*theta) and ri after we transform the original # point. if start + end != infinity: # Not a straight line: # Map the endpoints to 0 and infinity and the midpoint to 1. T = HyperbolicGeodesicUHP._crossratio_matrix(start, (start + end)/2, end) else: # Is a straight line: # Map the endpoints to 0 and infinity and another endpoint to 1. T = HyperbolicGeodesicUHP._crossratio_matrix(start, start + 1, end) x = moebius_transform(T, p) return self._dist_points(x, abs(x)*I)
def _moebius_sending(z, w): #UHP r""" Given two lists ``z`` and ``w`` of three points each in `\mathbb{CP}^1`, return the linear fractional transformation taking the points in ``z`` to the points in ``w``. EXAMPLES:: sage: from sage.geometry.hyperbolic_space.hyperbolic_model import HyperbolicModelUHP sage: from sage.geometry.hyperbolic_space.hyperbolic_isometry import moebius_transform sage: bool(abs(moebius_transform(HyperbolicModelUHP._moebius_sending([1,2,infinity],[3 - I, 5*I,-12]),1) - 3 + I) < 10^-4) True sage: bool(abs(moebius_transform(HyperbolicModelUHP._moebius_sending([1,2,infinity],[3 - I, 5*I,-12]),2) - 5*I) < 10^-4) True sage: bool(abs(moebius_transform(HyperbolicModelUHP._moebius_sending([1,2,infinity],[3 - I, 5*I,-12]),infinity) + 12) < 10^-4) True """ if len(z) != 3 or len(w) != 3: raise TypeError("moebius_sending requires each list to be three points long") A = HyperbolicGeodesicUHP._crossratio_matrix(z[0],z[1],z[2]) B = HyperbolicGeodesicUHP._crossratio_matrix(w[0],w[1],w[2]) return B.inverse() * A
def _mobius_sending(z, w): #UHP r""" Given two lists ``z`` and ``w`` of three points each in `\mathbb{CP}^1`, return the linear fractional transformation taking the points in ``z`` to the points in ``w``. EXAMPLES:: sage: from sage.geometry.hyperbolic_space.hyperbolic_model import HyperbolicModelUHP sage: from sage.geometry.hyperbolic_space.hyperbolic_isometry import mobius_transform sage: bool(abs(mobius_transform(HyperbolicModelUHP._mobius_sending([1,2,infinity],[3 - I, 5*I,-12]),1) - 3 + I) < 10^-4) True sage: bool(abs(mobius_transform(HyperbolicModelUHP._mobius_sending([1,2,infinity],[3 - I, 5*I,-12]),2) - 5*I) < 10^-4) True sage: bool(abs(mobius_transform(HyperbolicModelUHP._mobius_sending([1,2,infinity],[3 - I, 5*I,-12]),infinity) + 12) < 10^-4) True """ if len(z) != 3 or len(w) != 3: raise TypeError("mobius_sending requires each list to be three points long") A = HyperbolicGeodesicUHP._crossratio_matrix(z[0],z[1],z[2]) B = HyperbolicGeodesicUHP._crossratio_matrix(w[0],w[1],w[2]) return B.inverse() * A