# intersectionpoints of two hyperbola in asymptote?

I have written asymptote code:

\begin{asy}
import geometry;
//import g2geo;
unitsize(1cm);
defaultpen(fontsize(11pt));

pair A=(0.8,4); dot(Label("$A$",align=NW),A);
pair B=(0,0); dot(Label("$B$",align=SW),B);
pair C=(7,0); dot(Label("$C$",align=SE),C);
draw(A--B--C--A);

triangle t=triangle(A,B,C);
draw(circle(A,B,C));
point I=incenter(t); dot(Label("$I$",align=NW),I);
point M=midpoint(t.BC); dot(Label("$M$",align=NW),M);

circle b=incircle(t), c=excircle(t.BC);
draw(b,red); draw(c,red);

hyperbola hypB=hyperbola(M,b.C,b.r/2); draw(hypB,brown);
hyperbola hypC=hyperbola(M,c.C,c.r/2); draw(hypC,orange);

point[] temp=intersectionpoints(hypB,hypC);
//dot(Label("$t_0$",align=SE),temp[0]);

\end{asy}


When I draw 2 hyperbolas (as shown above) and find their intersections using the function intersectionpoints(hypB,hypC), it doesn't return any value.

• Where can one find the g2geo module?
– user194703
Commented Oct 5, 2019 at 14:16

Update : the bug in geometry.asy is fixed (and the original code works). See https://github.com/vectorgraphics/asymptote/commit/2a237885ddc65eb8db7fc9a8d2fa51c17a5b25a1 and https://github.com/vectorgraphics/asymptote/commit/d63f1d90e26cfc27d496daee95858ed03b78692a Tests and feedbacks are welcome.

First it seems that there is a bug into geometry.asy. For the hyperbola intersection, the routine is first to derive the corresponding quartic equation and then to use a quartic complex resolution and to extract real roots. In your example the equation is not degenerated and clearly there is bug : the routine does not accept a null coefficient in y^2 for both hyperbola.

Secondly, even if an hyperbola has two parts, the path casting extracts only one. It is why path hypB=hyperbola(M,b.C,b.r/2) gives an incomplete picture. It is possible to add the second part by hyperbola(b.C,M,b.r/2).

Please find a workaround (the geometry.asy specific intersectionpoints should be improved).

import geometry;
//import g2geo;
unitsize(1cm);
defaultpen(fontsize(11pt));

pair A=(0.8,4); dot(Label("$A$",align=NW),A);
pair B=(0,0); dot(Label("$B$",align=SW),B);
pair C=(7,0); dot(Label("$C$",align=SE),C);
draw(A--B--C--A);

triangle t=triangle(A,B,C);
draw(circle(A,B,C));
point I=incenter(t); dot(Label("$I$",align=NW),I);
point M=midpoint(t.BC); dot(Label("$M$",align=NW),M);

circle b=incircle(t), c=excircle(t.BC);
draw(b,red); draw(c,red);

path[] hypB=hyperbola(M,b.C,b.r/2)^^hyperbola(b.C,M,b.r/2);
draw(hypB,brown);
path[] hypC=hyperbola(M,c.C,c.r/2)^^hyperbola(c.C,M,c.r/2);
draw(hypC,orange);

pair[] tp=intersectionpoints(hypB,hypC);
for (int i=0;i<tp.length;++i)
{
dot(Label("$T_"+string(i)+"$",align=SE),tp[i]);
}


and the result

It works without problems if one replaces hyperbola by path. Note that I do not have the g2geo module.

\documentclass[border=3mm]{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=hyperbolae}
import geometry;
//import g2geo;
unitsize(1cm);
defaultpen(fontsize(11pt));

pair A=(0.8,4); dot(Label("$A$",align=NW),A);
pair B=(0,0); dot(Label("$B$",align=SW),B);
pair C=(7,0); dot(Label("$C$",align=SE),C);
draw(A--B--C--A);

triangle t=triangle(A,B,C);
draw(circle(A,B,C));
point I=incenter(t); dot(Label("$I$",align=NW),I);
point M=midpoint(t.BC); dot(Label("$M$",align=NW),M);

circle b=incircle(t), c=excircle(t.BC);
draw(b,red); draw(c,red);

path hypB=hyperbola(M,b.C,b.r/2); draw(hypB,brown);
path hypC=hyperbola(M,c.C,c.r/2); draw(hypC,orange);

pair[] isp=intersectionpoints(hypB,hypC);
dot(Label("$t_0$",align=SE),isp[0]);
dot(Label("$t_1$",align=SW),isp[1]);

\end{asypicture}
\end{document}


• Thanks Schrödinger's cat. May be the function intersectionpoints(hypB,hypC) error? Commented Oct 5, 2019 at 15:26
• @TranQuan I don't know. It seems to expect a path.
– user194703
Commented Oct 5, 2019 at 15:27
• Hi Schrödinger's cat, There are three intersects of (hypB,hypC). If use path, there are only two intersects. Commented Oct 5, 2019 at 15:33
• @TranQuan Really? I only see two of them.
– user194703
Commented Oct 5, 2019 at 15:35
• third point is the nine point center of triangle ABC. It not show with path. Commented Oct 5, 2019 at 15:38

This bug in geometry.asy was fixed in Asymptote version 2.57.