I want to find the intersection of two paths, a circle and an ellipse. Only one intersection is found. Why? Thanks.
Here is the MWE:
\documentclass[12pt]{article}
\usepackage[pdftex]{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc,3d,shapes, intersections}
\usepackage{xcolor}
\usepackage{tikz-3dplot}
\begin{document}
\begin{tikzpicture}
\coordinate (O) at (0,0);
\def\R{3cm}
\def\c1{(O) circle (\R)}
\fill[ball color=white!10, opacity=0.3, name path=c1] \c1;
\draw[rotate=42, name path=c3, yscale=0.5, color=red] \c1;
\path [name intersections={of=c1 and c3, by={c131, c132}}];
\node[] at (c131) {c131};
\node[] at (c132) {c132};
\end{tikzpicture}
\end{document}
Here the graph:
To expand a bit. It finds intersections in many cases but not in this. Here is my complete code so far:
\documentclass[12pt]{article}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{calc,3d,shapes, pgfplots.external, intersections}
\begin{document}
\begin{tikzpicture}[]
\coordinate (O) at (0,0);
\def\R{3cm}
%outside sphere
\def\c1{(O) circle (\R)}
\fill[ball color=white!10, opacity=0.3, name path=c1] \c1;
%one lune side
\draw[rotate=96, name path=c2, yscale=0.5] \c1;
%the other lune side
\draw[rotate=42, name path=c3, yscale=0.5, color=red] \c1;
% find intersections of each lune side with outside circle
\path [name intersections={of=c1 and c2,
by={c121, c122}}];
% perhaps a bug in intersections but I need to reverse the sign of c123
\path [name intersections={of=c1 and c3,
by={c131, c132}}];
% find intersections between c2 and c3
\path [name intersections={of=c2 and c3,
by={c231, c232, c233, c234}}];
% Locate points (a preview) uncomment the following lines
% to better understand the figure
\node[] at (c121) {c121};
\node[] at (c122) {c122};
\node[] at (c131) {c131};
\node[] at (c132) {c132};
\node[] at (c231) {c231};
\node[] at (c232) {c232};
\node[] at (c233) {c233};
\node[] at (c234) {c234};
\path[name path=c4, yscale=0.25 , rotate=42] \c1;
\end{tikzpicture}
\end{document}
Why does it find all the intersections in the other couple of ellipses and not in the points c131, c132?
\def\c1{...}
or, rather, you can't say this to mean what you want. The number is not allowed unless you change the cat codes or it is a single character command.\def\c1
does not define a macro with the namec1
which is, I think, what you believe it is doing. It defines a macro\c
which must always be followed by1
, which is entirely pointless.\newcommand*
is much safer here anyway and should always be preferred in LaTeX. (Isn't always possible, of course. But it is here.)\c
. This is not at all wise. It means that e.g.\c a
will give an error. If you used\newcommand*
you'd get some sort of error or warning.\def
won't complain - it just redefines\c
regardless of the fact that it is a basic, standard command.