# How to draw the intersection of a circle and a path in METAPOST

How do I draw only the two sides of the circle which would be left after subtracting the heavy red line?

\documentclass{article}

\usepackage{luacode}
\usepackage{luamplib}
\usepackage{calc}
\usepackage{xcolor}
\usepackage{forloop}

\setlength{\unitlength}{1bp}
\setlength{\parindent}{0sp}

\begin{document}
\pagestyle{empty}

\begin{picture}(0,0)
\put(0,-72){
\begin{mplibcode}
beginfig(1);

pair A, B, C, D, E, F, G, H, I, J;

A:=(72 bp,18 bp); B:=(135 bp,72 bp);
C:=(72 bp,135 bp); D:=(9 bp,72 bp);

draw A..B..C..D..cycle;

E :=(72 bp,144 bp);
F := (36 bp,108 bp);
G := (72 bp,72 bp);
H := (108 bp,36 bp);
I := (72 bp,0);

draw E..F..G..H..I withcolor red withpen pencircle scaled 9 bp;

endfig;
\end{mplibcode}}
\end{picture}
\end{document}


I do not know whether that is the best solution but at least it gets the intersections. (I did not use metafont in ages.)

\documentclass{article}

\usepackage{luacode}
\usepackage{luamplib}
\usepackage{calc}
\usepackage{xcolor}
\usepackage{forloop}

\setlength{\unitlength}{1bp}
\setlength{\parindent}{0sp}

\begin{document}
\pagestyle{empty}

\begin{picture}(0,0)
\put(0,-72){
\begin{mplibcode}
beginfig(1);

pair A, B, C, D, E, F, G, H, I, J;
path curve, circle;

A:=(72 bp,18 bp); B:=(135 bp,72 bp);
C:=(72 bp,135 bp); D:=(9 bp,72 bp);

circle = A..B..C..D..cycle;
draw circle;

E :=(72 bp,144 bp);
F := (36 bp,108 bp);
G := (72 bp,72 bp);
H := (108 bp,36 bp);
I := (72 bp,0);

curve=E..F..G..H..I;
draw curve withcolor red withpen pencircle scaled 9 bp;

dotlabel.ulft("1", curve intersectionpoint circle);

dotlabel.ulft("2", curve intersectionpoint subpath (4,6) of circle);

endfig;
\end{mplibcode}}
\end{picture}
\end{document}


• Thanks! I was able to use that to work out a good enough solution for my needs. Next up is pie slices. – WillAdams Mar 23 '19 at 20:11
• @WillAdams May I offer you this one? (Just kidding.;-) – user121799 Mar 23 '19 at 23:16
• Delightful! Managed to work out two cuts (the math/logic on doing it in a loop escaped me, though I managed to get it in OpenSCAD), and that's good enough for now. – WillAdams Mar 24 '19 at 13:37