# Drawing lines on a Poincaré ball model

• March 12th 2009, 05:42 AM
bkarpuz
Drawing lines on a Poincaré ball model
Dear all, hi again,

Is it possible to draw lines in a Poincaré ball model by Mathematica 6.0?
To draw a line on a Poincaré ball model, we need two point in the unit open ball, and such lines are circular arcs that pass through the given two points and intersect the boundary of the unit open ball orthogonally.

Thanks.
• March 19th 2009, 03:03 AM
bkarpuz
I have coded the following:
Code:

Manipulate[  Graphics[{{Blue, Circle[{0, 0}, s, {0, 2 Pi}]},   If[b c - a d == 0,     Line[{{a, b}, {c, d}}], {Red,     Circle[{(-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 + d s^2)/(       2 (a d - b c)), (       a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(       2 (b c - a d))},       Sqrt[((-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 + d s^2)/(         a d - b c))^2 + ((         a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(         b c - a d))^2 - 4 s^2]/2, {0, 2 Pi}]}], {PointSize[Large],     Point[{0, 0}]}, {PointSize[Medium],     Point[{a, b}]}, {PointSize[Medium], Point[{c, d}]}},   ImageSize -> 300], {{s, 1, "s"}, 1, 5,   Appearance -> "Labeled"}, {{a, 1/2, "a"}, -s, s,   Appearance -> "Labeled"}, {{b, 1/2, "b"}, -Sqrt[-a^2 + s^2],   Sqrt[-a^2 + s^2], Appearance -> "Labeled"}, {{c, -1/3, "c"}, -s, s,   Appearance -> "Labeled"}, {{d, 1/3, "d"}, -Sqrt[-c^2 + s^2],   Sqrt[-c^2 + s^2], Appearance -> "Labeled"}]
Here $s$ is the radius of the blue ball, $P=(a,b)$ and $Q=(c,d)$ are two points inside the blue ball.
The problem now is how to draw the arc of the red circle that that combines $P$ and $Q$. :S
http://img8.imageshack.us/img8/7016/poincaredrawing.jpg
• March 19th 2009, 04:30 AM
bkarpuz
Quote:

Originally Posted by bkarpuz
I have coded the following:
Code:

Manipulate[  Graphics[{{Blue, Circle[{0, 0}, s, {0, 2 Pi}]},   If[b c - a d == 0,     Line[{{a, b}, {c, d}}], {Red,     Circle[{(-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 + d s^2)/(       2 (a d - b c)), (       a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(       2 (b c - a d))},       Sqrt[((-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 + d s^2)/(         a d - b c))^2 + ((         a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(         b c - a d))^2 - 4 s^2]/2, {0, 2 Pi}]}], {PointSize[Large],     Point[{0, 0}]}, {PointSize[Medium],     Point[{a, b}]}, {PointSize[Medium], Point[{c, d}]}},   ImageSize -> 300], {{s, 1, "s"}, 1, 5,   Appearance -> "Labeled"}, {{a, 1/2, "a"}, -s, s,   Appearance -> "Labeled"}, {{b, 1/2, "b"}, -Sqrt[-a^2 + s^2],   Sqrt[-a^2 + s^2], Appearance -> "Labeled"}, {{c, -1/3, "c"}, -s, s,   Appearance -> "Labeled"}, {{d, 1/3, "d"}, -Sqrt[-c^2 + s^2],   Sqrt[-c^2 + s^2], Appearance -> "Labeled"}]
Here $s$ is the radius of the blue ball, $P=(a,b)$ and $Q=(c,d)$ are two points inside the blue ball.
The problem now is how to draw the arc of the red circle that that combines $P$ and $Q$. :S
http://img8.imageshack.us/img8/7016/poincaredrawing.jpg

The following code works fine:
Code:

Manipulate[  Graphics[{{Blue, Circle[{0, 0}, s, {0, 2 Pi}]},   If[b c - a d == 0,     Line[{{a, b}, {c, d}}], {Red,     Circle[{(-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 + d s^2)/(       2 (a d - b c)), (       a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(       2 (b c - a d))},       Sqrt[((-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 + d s^2)/(         a d - b c))^2 + ((         a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(         b c - a d))^2 - 4 s^2]/       2, {Min[If[         b >= (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(           2 (b c - a d)),         ArcCos[Dot[{a - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +               d s^2)/(2 (a d - b c)),             b - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}, {1, 0}]/           Norm[{a - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +               d s^2)/(2 (a d - b c)),             b - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}]],         2 Pi - ArcCos[           Dot[{a - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 + d s^2)/(               2 (a d - b c)),               b - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}, {1, 0}]/             Norm[{a - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +                 d s^2)/(2 (a d - b c)),               b - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}]]],         If[d >= (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(           2 (b c - a d)),         ArcCos[Dot[{c - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +               d s^2)/(2 (a d - b c)),             d - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}, {1, 0}]/           Norm[{c - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +               d s^2)/(2 (a d - b c)),             d - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}]],         2 Pi - ArcCos[           Dot[{c - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 + d s^2)/(               2 (a d - b c)),               d - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}, {1, 0}]/             Norm[{c - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +                 d s^2)/(2 (a d - b c)),               d - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}]]]],       Max[If[b >= (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(           2 (b c - a d)),         ArcCos[Dot[{a - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +               d s^2)/(2 (a d - b c)),             b - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}, {1, 0}]/           Norm[{a - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +               d s^2)/(2 (a d - b c)),             b - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}]],         2 Pi - ArcCos[           Dot[{a - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 + d s^2)/(               2 (a d - b c)),               b - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}, {1, 0}]/             Norm[{a - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +                 d s^2)/(2 (a d - b c)),               b - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}]]],         If[d >= (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(           2 (b c - a d)),         ArcCos[Dot[{c - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +               d s^2)/(2 (a d - b c)),             d - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}, {1, 0}]/           Norm[{c - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +               d s^2)/(2 (a d - b c)),             d - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}]],         2 Pi - ArcCos[           Dot[{c - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 + d s^2)/(               2 (a d - b c)),               d - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}, {1, 0}]/             Norm[{c - (-b c^2 + a^2 d + b^2 d - b d^2 - b s^2 +                 d s^2)/(2 (a d - b c)),               d - (a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(               2 (b c - a d))}]]]]}]}], {PointSize[Medium],     Point[{0, 0}]}, {PointSize[Medium],     Point[{a, b}]}, {PointSize[Medium], Point[{c, d}]}},   ImageSize -> 300], {{s, 1, "s"}, 1, 5,   Appearance -> "Labeled"}, Delimiter, {{a, 1/2, "a"}, -s, s,   Appearance -> "Labeled"}, {{b, 1/2, "b"}, -Sqrt[-a^2 + s^2],   Sqrt[-a^2 + s^2],   Appearance -> "Labeled"}, Delimiter, {{c, -1/3, "c"}, -s, s,   Appearance -> "Labeled"}, {{d, 1/3, "d"}, -Sqrt[-c^2 + s^2],   Sqrt[-c^2 + s^2], Appearance -> "Labeled"}]
• March 21st 2009, 02:50 PM
bkarpuz
Code:

(*returns the first component of the center of the ortogonal circle*) \  orcice1[s_, a_, b_, c_, d_] := (-b c^2 + a^2 d + b^2 d - b d^2 -   b s^2 + d s^2)/(2 (a d - b c)); (*returns the second component of the center of the ortogonal circle*) \  orcice2[s_, a_, b_, c_, d_] := (   a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(2 (b c - a d)); (*returns the radius component of the ortogonal circle*)  orcira[s_, a_, b_, c_, d_] :=   Sqrt[(2 orcice1[s, a, b, c, d])^2 + (2 orcice2[s, a, b, c, d])^2 -   4 s^2]/2; (*returns the argument of the number a+\[ImaginaryI]b between 0 and \ \[Pi]*) ar02pi[a_, b_] :=   If[Arg[a + \[ImaginaryI] b] <= 0, Arg[a + \[ImaginaryI] b] + 2 Pi,   Arg[a + \[ImaginaryI] b]]; (*arc angle of the ortogonal circle combining (a,b) and (c,d) in the \ Poincaré ball with the radious s*) aran[s_, a_, b_, c_, d_] :=   VectorAngle[{a - orcice1[s, a, b, c, d],     b - orcice2[s, a, b, c, d]}, {c - orcice1[s, a, b, c, d],     d - orcice2[s, a, b, c, d]}]; (*angle of the rotation transformation of the ortogonal circle's arc \ (a,b) and (c,d) in the Poincaré ball with the radious s*) arro[s_, a_, b_, c_, d_] :=   If[Min[ar02pi[a - orcice1[s, a, b, c, d],       b - orcice2[s, a, b, c, d]],       ar02pi[c - orcice1[s, a, b, c, d],       d - orcice2[s, a, b, c, d]]] + aran[s, a, b, c, d] ==     Max[ar02pi[a - orcice1[s, a, b, c, d],       b - orcice2[s, a, b, c, d]],     ar02pi[c - orcice1[s, a, b, c, d], d - orcice2[s, a, b, c, d]]],   Min[ar02pi[a - orcice1[s, a, b, c, d], b - orcice2[s, a, b, c, d]],     ar02pi[c - orcice1[s, a, b, c, d], d - orcice2[s, a, b, c, d]]],   Max[ar02pi[a - orcice1[s, a, b, c, d], b - orcice2[s, a, b, c, d]],     ar02pi[c - orcice1[s, a, b, c, d],     d - orcice2[s, a, b, c, d]]]]; (*draws a gyroline passing through (a,b) and (c,d) in the Poincaré \ ball with the radious s*) gyroline[s_, a_, b_, c_, d_] :=   If[a d - b c ==     0, {{Green, Opacity -> 0.4, Line[{{a, b}, {c, d}}]}, {Red,     PointSize[Large], Point[{a, b}]}, {Blue, PointSize[Large],     Point[{c, d}]}}, {Rotate[     Circle[{ orcice1[s, a, b, c, d], orcice2[s, a, b, c, d]},       orcira[s, a, b, c, d], {0, aran[s, a, b, c, d]}],     arro[s, a, b, c, d], {orcice1[s, a, b, c, d],       orcice2[s, a, b, c, d]}], {Red, PointSize[Large],     Point[{a, b}]}, {Blue, PointSize[Large], Point[{c, d}]}}]; (*manipulates the radius together with two points*) Manipulate[  Graphics[{{Blue, Circle[{0, 0}, 1, {0, 2 Pi}]},   gyroline[s, ar*Cos[aa], ar*Sin[aa], br*Cos[ba], br*Sin[ba]]}], {{s,     1, "s"}, 1, 5,   Appearance -> "Labeled"}, Delimiter, {{ar, 0.43, "ar"}, 0, s,   Appearance -> "Labeled"}, {{aa, 1.67133, "aa"}, 0, 2 Pi,   Appearance -> "Labeled"}, Delimiter, {{br, 0.366, "br"}, 0, s,   Appearance -> "Labeled"}, {{ba, 4.73752, "ba"}, 0, 2 Pi,   Appearance -> "Labeled"}]
I have problems with the code above.
I want to explain my algorithm for drawing a gyroline to request some help about my mistake:
Let $C$ be the unit disc, and $P$ and $Q$ be two points inside $C$.
If the angle between $P$ and $Q$ is $\pi$, then the gyroline passing through the points $P$ and $Q$ is the straight segment joining these two points.
If not, then we draw the orthogonal circle $C^{\prime}$ to $C$, which passes through the given points $P$ and $Q$, and the gyroline is the shorter arc segment between $P$ and $Q$.
To draw the gyroline in this present case, I first calculate the center $M^{\prime}$ and the radius $R^{\prime}$ of the orthogonal circle $C^{\prime}$, and then obtain the points $P^{\prime}$ and $Q^{\prime}$ by transforming the points $P$ and $Q$ by the transform vector $M^{\prime}$, respectively, i.e., $P^{\prime}:=P-M^{\prime}$ and $Q^{\prime}:=Q-M^{\prime}$.
Let $\theta$ denote the angle between the vectors $P^{\prime}$ and $Q^{\prime}$.
Then I draw a circle arc $J$ of $\theta$ radian length centered at the origin $M^{\prime}$.
Now the problem is how much radians should I rotate the arc $J$ about the point $M^{\prime}$ to fix it between the points $P^{\prime}$ and $Q^{\prime}$.
My solution that I believed to be true was as follows:
Let $\varphi$ be the rotation angle.
If $\min\{\mathrm{Arg}(P^{\prime}),\mathrm{Arg}(Q^{\pr ime})\}+\theta=\max\{\mathrm{Arg}(P^{\prime}),\mat hrm{Arg}(Q^{\prime})\}$ (the transformed arc $J^{\prime}:=J-M^{\prime}$ does not intersect the segment combining the points $(0,0)$ and $(1,0)$), then $\varphi:=\min\{\mathrm{Arg}(P^{\prime}),\mathrm{Ar g}(Q^{\prime})\}$ radians, where $\mathrm{Arg}$ is the positive angle between the given vector and $(1,0)$ (the argument of the corresponding complex number).
Otherwise (when $J^{\prime}$ intersects the segment combining the points $(0,0)$ and $(1,0)$), $\varphi:=\max\{\mathrm{Arg}(P^{\prime}),\mathrm{Ar g}(Q^{\prime})$.
But the code gives error while drawing the latter case.

Thanks.
• March 21st 2009, 03:57 PM
bkarpuz
Quote:

Originally Posted by bkarpuz
Code:

(*returns the first component of the center of the ortogonal circle*) \  orcice1[s_, a_, b_, c_, d_] := (-b c^2 + a^2 d + b^2 d - b d^2 -   b s^2 + d s^2)/(2 (a d - b c)); (*returns the second component of the center of the ortogonal circle*) \  orcice2[s_, a_, b_, c_, d_] := (   a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(2 (b c - a d)); (*returns the radius component of the ortogonal circle*)  orcira[s_, a_, b_, c_, d_] :=   Sqrt[(2 orcice1[s, a, b, c, d])^2 + (2 orcice2[s, a, b, c, d])^2 -   4 s^2]/2; (*returns the argument of the number a+\[ImaginaryI]b between 0 and \ \[Pi]*) ar02pi[a_, b_] :=   If[Arg[a + \[ImaginaryI] b] <= 0, Arg[a + \[ImaginaryI] b] + 2 Pi,   Arg[a + \[ImaginaryI] b]]; (*arc angle of the ortogonal circle combining (a,b) and (c,d) in the \ Poincaré ball with the radious s*) aran[s_, a_, b_, c_, d_] :=   VectorAngle[{a - orcice1[s, a, b, c, d],     b - orcice2[s, a, b, c, d]}, {c - orcice1[s, a, b, c, d],     d - orcice2[s, a, b, c, d]}]; (*angle of the rotation transformation of the ortogonal circle's arc \ (a,b) and (c,d) in the Poincaré ball with the radious s*) arro[s_, a_, b_, c_, d_] :=   If[Min[ar02pi[a - orcice1[s, a, b, c, d],       b - orcice2[s, a, b, c, d]],       ar02pi[c - orcice1[s, a, b, c, d],       d - orcice2[s, a, b, c, d]]] + aran[s, a, b, c, d] ==     Max[ar02pi[a - orcice1[s, a, b, c, d],       b - orcice2[s, a, b, c, d]],     ar02pi[c - orcice1[s, a, b, c, d], d - orcice2[s, a, b, c, d]]],   Min[ar02pi[a - orcice1[s, a, b, c, d], b - orcice2[s, a, b, c, d]],     ar02pi[c - orcice1[s, a, b, c, d], d - orcice2[s, a, b, c, d]]],   Max[ar02pi[a - orcice1[s, a, b, c, d], b - orcice2[s, a, b, c, d]],     ar02pi[c - orcice1[s, a, b, c, d],     d - orcice2[s, a, b, c, d]]]]; (*draws a gyroline passing through (a,b) and (c,d) in the Poincaré \ ball with the radious s*) gyroline[s_, a_, b_, c_, d_] :=   If[a d - b c ==     0, {{Green, Opacity -> 0.4, Line[{{a, b}, {c, d}}]}, {Red,     PointSize[Large], Point[{a, b}]}, {Blue, PointSize[Large],     Point[{c, d}]}}, {Rotate[     Circle[{ orcice1[s, a, b, c, d], orcice2[s, a, b, c, d]},       orcira[s, a, b, c, d], {0, aran[s, a, b, c, d]}],     arro[s, a, b, c, d], {orcice1[s, a, b, c, d],       orcice2[s, a, b, c, d]}], {Red, PointSize[Large],     Point[{a, b}]}, {Blue, PointSize[Large], Point[{c, d}]}}]; (*manipulates the radius together with two points*) Manipulate[  Graphics[{{Blue, Circle[{0, 0}, 1, {0, 2 Pi}]},   gyroline[s, ar*Cos[aa], ar*Sin[aa], br*Cos[ba], br*Sin[ba]]}], {{s,     1, "s"}, 1, 5,   Appearance -> "Labeled"}, Delimiter, {{ar, 0.43, "ar"}, 0, s,   Appearance -> "Labeled"}, {{aa, 1.67133, "aa"}, 0, 2 Pi,   Appearance -> "Labeled"}, Delimiter, {{br, 0.366, "br"}, 0, s,   Appearance -> "Labeled"}, {{ba, 4.73752, "ba"}, 0, 2 Pi,   Appearance -> "Labeled"}]
I have problems with the code above.
I want to explain my algorithm for drawing a gyroline to request some help about my mistake:
Let $C$ be the unit disc, and $P$ and $Q$ be two points inside $C$.
If the angle between $P$ and $Q$ is $\pi$, then the gyroline passing through the points $P$ and $Q$ is the straight segment joining these two points.
If not, then we draw the orthogonal circle $C^{\prime}$ to $C$, which passes through the given points $P$ and $Q$, and the gyroline is the shorter arc segment between $P$ and $Q$.
To draw the gyroline in this present case, I first calculate the center $M^{\prime}$ and the radius $R^{\prime}$ of the orthogonal circle $C^{\prime}$, and then obtain the points $P^{\prime}$ and $Q^{\prime}$ by transforming the points $P$ and $Q$ by the transform vector $M^{\prime}$, respectively, i.e., $P^{\prime}:=P-M^{\prime}$ and $Q^{\prime}:=Q-M^{\prime}$.
Let $\theta$ denote the angle between the vectors $P^{\prime}$ and $Q^{\prime}$.
Then I draw a circle arc $J$ of $\theta$ radian length centered at the origin $M^{\prime}$.
Now the problem is how much radians should I rotate the arc $J$ about the point $M^{\prime}$ to fix it between the points $P^{\prime}$ and $Q^{\prime}$.
My solution that I believed to be true was as follows:
Let $\varphi$ be the rotation angle.
If $\min\{\mathrm{Arg}(P^{\prime}),\mathrm{Arg}(Q^{\pr ime})\}+\theta=\max\{\mathrm{Arg}(P^{\prime}),\mat hrm{Arg}(Q^{\prime})\}$ (the transformed arc $J^{\prime}:=J-M^{\prime}$ does not intersect the segment combining the points $(0,0)$ and $(1,0)$), then $\varphi:=\min\{\mathrm{Arg}(P^{\prime}),\mathrm{Ar g}(Q^{\prime})\}$ radians, where $\mathrm{Arg}$ is the positive angle between the given vector and $(1,0)$ (the argument of the corresponding complex number).
Otherwise (when $J^{\prime}$ intersects the segment combining the points $(0,0)$ and $(1,0)$), $\varphi:=\max\{\mathrm{Arg}(P^{\prime}),\mathrm{Ar g}(Q^{\prime})$.
But the code gives error while drawing the latter case.

Thanks.

Okay I got the solution.
In the latter case above, I rotate the points $P^{\prime}$ and $Q^{\prime}$ by the angle $\pi$ around the origin $O$, then consider the first case by increasing its rotation angle by $\pi$.
The correct code is given below:

Correct code for the gyroline
Code:

(*returns the first component of the center of the ortogonal circle*) \  orcice1[s_, a_, b_, c_, d_] := (-b c^2 + a^2 d + b^2 d - b d^2 -   b s^2 + d s^2)/(2 (a d - b c)); (*returns the second component of the center of the ortogonal circle*) \  orcice2[s_, a_, b_, c_, d_] := (   a^2 c + b^2 c - a c^2 - a d^2 - a s^2 + c s^2)/(2 (b c - a d)); (*returns the radius component of the ortogonal circle*)  orcira[s_, a_, b_, c_, d_] :=   Sqrt[(orcice1[s, a, b, c, d])^2 + (orcice2[s, a, b, c, d])^2 -   s^2]; (*returns the argument of the number a+\[ImaginaryI]b between 0 and \ \[Pi]*) ar02pi[a_, b_] :=   If[Arg[a + \[ImaginaryI] b] <= 0, Arg[a + \[ImaginaryI] b] + 2 Pi,   Arg[a + \[ImaginaryI] b]]; (*arc angle of the ortogonal circle combining (a,b) and (c,d) in the \ Poincaré ball with the radious s*) aran[s_, a_, b_, c_, d_] :=   VectorAngle[{a - orcice1[s, a, b, c, d],     b - orcice2[s, a, b, c, d]}, {c - orcice1[s, a, b, c, d],     d - orcice2[s, a, b, c, d]}]; (*draws a gyroline passing through (a,b) and (c,d) in the Poincaré \ ball with the radious s*) gyroline[s_, a_, b_, c_, d_] :=   If[a d - b c == 0, Line[{{a, b}, {c, d}}],   If[Min[ar02pi[a - orcice1[s, a, b, c, d],         b - orcice2[s, a, b, c, d]],       ar02pi[c - orcice1[s, a, b, c, d],         d - orcice2[s, a, b, c, d]]] + aran[s, a, b, c, d] ==     Max[ar02pi[a - orcice1[s, a, b, c, d],       b - orcice2[s, a, b, c, d]],       ar02pi[c - orcice1[s, a, b, c, d], d - orcice2[s, a, b, c, d]]],     Rotate[Circle[{ orcice1[s, a, b, c, d], orcice2[s, a, b, c, d]},       orcira[s, a, b, c, d], {0, aran[s, a, b, c, d]}],     Min[ar02pi[a - orcice1[s, a, b, c, d],       b - orcice2[s, a, b, c, d]],       ar02pi[c - orcice1[s, a, b, c, d],       d - orcice2[s, a, b, c, d]]], {orcice1[s, a, b, c, d],       orcice2[s, a, b, c, d]}],     Rotate[Circle[{ orcice1[s, a, b, c, d], orcice2[s, a, b, c, d]},       orcira[s, a, b, c, d], {0, aran[s, a, b, c, d]}],     Min[ar02pi[-a - orcice1[s, -a, -b, -c, -d], -b -         orcice2[s, -a, -b, -c, -d]],       ar02pi[-c - orcice1[s, -a, -b, -c, -d], -d -         orcice2[s, -a, -b, -c, -d]]] + \[Pi], {orcice1[s, a, b, c,       d], orcice2[s, a, b, c, d]}]]];
Code for the example which gives error in the previous codes
Code:

Manipulate[  Graphics[{{Blue, Circle[{0, 0}, 1, {0, 2 Pi}]},   gyroline[s, ar*Cos[aa], ar*Sin[aa], br*Cos[ba], br*Sin[ba]]}], {{s,     1, "s"}, 1, 5,   Appearance -> "Labeled"}, Delimiter, {{ar, 0.43, "ar"}, 0, s,   Appearance -> "Labeled"}, {{aa, 1.67133, "aa"}, 0, 2 Pi,   Appearance -> "Labeled"}, Delimiter, {{br, 0.366, "br"}, 0, s,   Appearance -> "Labeled"}, {{ba, 4.73752, "ba"}, 0, 2 Pi,   Appearance -> "Labeled"}]