# How to find the intersection of circles to create hyperbolas in Asymptote?

I have an asymptote file that plots several concentric circles.

``````settings.outformat="pdf";
import geometry;
unitsize(2cm);
int n=20;
for(int k=0; k<n; ++k){
for(int i=0; i<20; ++i)
draw(scale(sqrt(2)*((k/n)+i)/6)*unitcircle,red);
clip(shift(-2,-2)*yscale(4)*xscale(6)*unitsquare);
for(int i=0; i<20; ++i)
draw(shift(2,0)*scale(sqrt(2)*((k/n)+i)/6)*unitcircle,blue);
clip(shift(-2,-2)*yscale(4)*xscale(6)*unitsquare);
}
`````` If you look at the left most circled points, it appears to create a branch of a hyperbola. How can I use asymptote to find this intersection and plot the hyperbola?

• This looks sort of like TikZ code. So you would have to name all the paths (e.g. `left\i` and `right\i`) and use the intersections tikzlibrary. Oct 11 '19 at 13:13
• It would be helpful if you included a paragraph of text explaining what you want. I have a guess by comparing your image and your title, but I'm not entirely sure. It would also be good to fix the formatting of your code so that it looks like code. Oct 11 '19 at 13:13
• nice question! `import geometry;` is not necessary ` Oct 13 '19 at 1:52
• Thank U: Teepeemm; John Kormylo; Black Mild (vn) :) Oct 13 '19 at 2:17 Something like this?

``````settings.outformat="pdf";
size(9cm);
int n=20;
pair[][] hyPoint;
guide f1(int k, int i){return scale(sqrt(2)*((k/n)+i)/6)*unitcircle;}
guide f2(int k, int i){return shift(2,0)*f1(k,i);}

for(int k=0; k<n; ++k){
for(int i=0; i<n; ++i){
draw(f1(k,i),darkblue+ 0.2*bp);
draw(f2(k,i),yellow  +0.2*bp);
}
}

hyPoint=new pair[];
for(int j=0;j<n-8;++j){
hyPoint.append(intersectionpoints(f1(n-1,j),f2(n-1,j+8)));
}

hyPoint=new pair[];
for(int j=0;j<n-8;++j){
hyPoint.append(intersectionpoints(f1(n-1,j),f2(n-1,j+8-1)));
}

dot(hyPoint,darkblue,UnFill);
dot(hyPoint,yellow,UnFill);

clip(shift(-2,-2)*yscale(4)*xscale(6)*unitsquare);
``````
• Thank U so much! Oct 13 '19 at 2:30

I'm going to come at this differently and not actually find the intersections.

Unwrapping everything, it appears that you have circles at the origin of various radii, and circles at (2,0) of various radii. The hyperbolas are formed when you start at an intersection of two of these circles and increase (or decrease) the radii of the two intersecting circles by the same amount, and connect the old and new intersections. In other words, the hyperbolas are the collection of (x,y) such that:
`dist( (0,0) , (x,y) ) - dist( (2,0) , (x,y) ) = 2a`
for various values of `a` (where `-1 < a < 1`).

A common derivation shows this is the hyperbola `(x-1)^2/a^2 - y^2/(1-a^2) = 1`. This is easiest to plot with the parametric coordinates `(1+a*sec(t),sqrt(1-a^2)*tan(t))` for `-90 < t < 90` and `90 < t < 270`.

``````settings.outformat="pdf";
import geometry;
unitsize(2cm);
int n=20;
for(int k=0; k<n; ++k){
for(int i=0; i<20; ++i)
draw(scale(sqrt(2)*((k/n)+i)/6)*unitcircle,red);
for(int i=0; i<20; ++i)
draw(shift(2,0)*scale(sqrt(2)*((k/n)+i)/6)*unitcircle,blue);
}

for ( int a = 1 ; a <= 8 ; ++a ) {
pair f(real t) {
return (1+a/(9*Cos(t)),sqrt(81-a^2)*Tan(t)/9);
}
draw(graph(f,-89,89),green+linewidth(1)); // right halves
draw(graph(f,91,269),green+linewidth(1)); // left halves
}

clip(shift(-2,-2)*yscale(4)*xscale(6)*unitsquare); // relocated
`````` This doesn't hit the intersection points (most notably near the foci), but it does plot the hyperbolas.

• Thank Teepeemm! Oct 13 '19 at 2:19