SageMath: Create a triangle with specific angles in Hyperbolic space, eg., Upper Halfspace Plane

14 views Asked by At

I'm trying to create a triangle in hyperbolic space, specifically in the Upper Halfspace Plane, using SageMath. I would like to specify the angles of the triangle and generate its corresponding geometric representation.

I came across https://mathoverflow.net/a/401866/161218 and tried to implement but got the issue described in the post. I know this is a cross-post and not recommended but I would like to resolve this issue as soon as possible so let me post here as well.

Could anyone provide guidance on how to achieve this using SageMath? Any example code or resources would be greatly appreciated. Thank you!

Algorithm: https://mathoverflow.net/a/401866/161218

a1, a2, a3 = pi / 4, pi / 4, pi / 4
c1 = (cos(a1) + cos(a2) * cos(a3)) / sin(a2) * sin(a3)
c2 = (cos(a2) + cos(a3) * cos(a1)) / sin(a3) * sin(a1)
c3 = (cos(a3) + cos(a1) * cos(a2)) / sin(a1) * sin(a2)
a, b, p, q, r = var("a b p q r")

""" a, b, p, q, r are used in the following coordinates in Hyperboloid model
p1 = (0.0, 0.0, 1.0)
p2 = (0.0, a, b)
p3 = (p, q, r)
"""

eq = list()
eq += [b == c3]
eq += [r == c2]
eq += [a == sqrt((b ** 2) - 1)]
eq += [-c1 == a * q - b * r]
eq += [(p ** 2) == (r ** 2) - 1 - (q ** 2)]
solns = solve(eq, a, b, p, q, r, solution_dict=True)
solns = [[s[a].n(8), s[b].n(8), s[p].n(8), s[q].n(8), s[r].n(8)] for s in solns]
print(solns)
a, b, p, q, r = solns[0]  # pick the first solution
print(a, b, p, q, r)

# Pre-computed Constant for a, b, p, q, r for a1, a2, a3 = pi / 4, pi / 4, pi / 4
# a, b, p, q, r = 0.68, 1.2, -0.57, 0.37, 1.2

# Map the points in Hyperboloid to UHP
p1 = (0.1, 0.1)  # (0.0, 0.0)
p2 = (0.0 / 1 + b, a / 1 + b)
p3 = (p / 1 + r, q / 1 + r)
print(p1, p2, p3)

p1, p2, p3 = CC(p1), CC(p2), CC(p3)

p = hyperbolic_polygon(pts=[p1, p2, p3], model="UHP", fill=True, alpha=0.3)

UHP = HyperbolicPlane().UHP()
p1 = UHP.get_point(p1)
p2 = UHP.get_point(p2)
p3 = UHP.get_point(p3)
l1 = UHP.get_geodesic(p1, p2)
l2 = UHP.get_geodesic(p2, p3)
l3 = UHP.get_geodesic(p1, p3)
print(l1, l2, l3)
print(l1.angle(l2) * 180, l2.angle(l3) * 180, l3.angle(l1) * 180)

g = Graphics()
g += p.plot()
g.show(axes=True)

0

There are 0 answers