tikz add tag
Anonymous 1123
Find intersection of two circles `(ABC)` and `(ABD)` where 
```
(-4, 2, 3) coordinate (A)
		(1, -2, 6) coordinate (B)
		(1, 5, 7) coordinate (C) 
		(5,2,6) coordinate (D)
```
This picture is drawn with Geosplan - Geospacw [here](http://www.aid-creem.org/)
![ScreenHunter 973.png](/image?hash=ceabe971728d06f10331d419718ce31df3cf61b6890d19d2dd75965de3f40386)

I copied this code from comment
```
\documentclass[border=2mm,tikz]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3dtools,intersections}
\begin{document}
	\tdplotsetmaincoords{60}{150}
	\begin{tikzpicture}[scale=1,tdplot_main_coords,line join = round, 
		line cap = round, declare function={R=5;}]
		\path
		(1,2,3) coordinate (I)
		(-4, 2, 3) coordinate (A)
		(1, -2, 6) coordinate (B)
		(1, 5, 7) coordinate (C) 
		(5,2,6) coordinate (D)
		;
		\path[every path/.append style={name path global=c1}] pic{3d circle through 3 points={%
				A={(A)},B={(B)},C={(C)},center name=H}};
		\path[every path/.append style={name path global=c2}] pic{3d circle through 3 points={% 
				A={(A)},B={(B)},C={(D)},center name= K}};
		%\path [name intersections={of=c1 and c2}];
		
		\begin{scope}[shift={(I)}]
			\draw[tdplot_screen_coords] (I) circle[radius=R]; 
		\end{scope}	
		\path[name intersections={of=c1 and c2,total=\t}]
		%\pgfextra{\typeout{\t}}
		foreach \X in {1,...,\t}
		{(intersection-\X) node[circle,draw,inner sep=1ex,label=above:$\X$]{}};
		\path foreach \p/\g in {I/0,A/90,B/90,C/90,D/90}
		{ (\p) node[circle,fill,inner sep=1pt,label=\g:{{$\p$}}]{}};
	\end{tikzpicture}
\end{document} 
```
I got incorrect result
![ScreenHunter 974.png](/image?hash=63e35a785ae456061cb9cb0a0857a233d959bf503f411d0fed7e3fd9c799b884)

How can I correct it?
Top Answer
user 3.14159
It is very "unlikely" that two circles in 3d intersect in two points. If this happens for two completely specified circles, the system is "overconstrained" in the sense that one can derive the intersections in different ways. The procedure here is
1. Project the center of the first circle, `H` on the plane in which the other circle lies. Call this projection `H'`. 
2. Project the center of the first circle, `K` on the plane in which the other circle lies. Call this projection `K'`.
3. Compute the intersection between the lines `H--K'` and `H'--K`. Generally these lines do not intersect, but if the circles intersect in two points, they do. Call this intersection `P`.
4. The intersections have a distance from `P` which is given by `p=sqrt(r_H^2-d(H,P)^2)`, where `r_H` is the radius of the circle around `H`. It is also given by `sqrt(r_K^2-d(K,P)^2)`, where `r_K` is the radius of the circle aroung `K`.  `d(H,P)` and `d(K,P)` are the distances between `H` and `P`, and `K` and `P`, respectively. This is another manifestation of the statement that the system is "overconstrained".
5. The intersections are `I_i=P\pm p*n`, where `n` is the normal of the plane spanned by `P`, `H` and `K`.

This is the corresponding code. It does not contain cross-checks if the circles really intersect in two points, it just follows the above procedure.
```
\documentclass[border=2mm,tikz]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
	\tdplotsetmaincoords{60}{150}
	\begin{tikzpicture}[scale=1,tdplot_main_coords,line join = round, 
		line cap = round, declare function={R=5;}]
		\path
		(1,2,3) coordinate (I)
		(-4, 2, 3) coordinate (A)
		(1, -2, 6) coordinate (B)
		(1, 5, 7) coordinate (C) 
		(5,2,6) coordinate (D);
	\path pic{3d circle through 3 points={%
			A={(A)},B={(B)},C={(C)},center name=H}};
    \path pic{3d circle through 3 points={% 
					A={(A)},B={(B)},C={(D)},center name= K}};
    \tikzset{3d/plane through={(A) and (B) and (C) named pABC},
		3d/plane through={(A) and (B) and (D) named pABD}}	
    \path[3d/project={(H) on pABD}] coordinate (H')
	 [3d/project={(K) on pABC}] coordinate (K');						
	\tikzset{3d/line through={(H) and (K') named l1},
		3d/line through={(K) and (H') named l2}} 
	\path[3d/intersection of={l1 with l2}]	coordinate (P);
	\path[overlay,3d coordinate={(n)=(H)-(P)x(K)-(P)}];
	% normalization of n
	\pgfmathsetmacro{\myn}{sqrt(TD("(n)o(n)"))}
	% radius of first circle around H
	\pgfmathsetmacro{\myrA}{sqrt(TD("(A)-(H)o(A)-(H)"))}
	% distance H--P
	\pgfmathsetmacro{\myrB}{sqrt(TD("(P)-(H)o(P)-(H)"))}
	% distance P to intersections
	\pgfmathsetmacro{\myrC}{sqrt(\myrA*\myrA-\myrB*\myrB)}
	% prefactor in linear combinations
	\pgfmathsetmacro{\myp}{\myrC/\myn}
	% build intersections
	\path[overlay,3d coordinate={(I_1)=(P)+\myp*(n)},
		3d coordinate={(I_2)=(P)-\myp*(n)}];
	% mark intersections	
	\path[red] foreach \X in {1,2}
	{(I_\X) node[circle,draw,inner sep=1ex,label=below:{$I_\X$}] {}};	
	%\path [name intersections={of=c1 and c2}];
 
	\begin{scope}[shift={(I)}]
		\draw[tdplot_screen_coords] (I) circle[radius=R]; 
	\end{scope}	
    \path foreach \p/\g in {I/0,A/90,B/90,C/90,D/90,H'/90,H'/90,P/90}
    { (\p) node[circle,fill,inner sep=1pt,label=\g:{{$\p$}}]{}};
\end{tikzpicture}
\end{document} 
```
![Screen Shot 2020-12-01 at 6.31.08 PM.png](/image?hash=d179f6e3e63941ca3b881888ff3d2b3c0e14ca7f75ed86781f6d12a2af7a6382)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.