Graphics, Figures & TablesIntersection between two curves 3D

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
rhum187
Posts: 1
Joined: Thu Jun 26, 2014 10:23 am

Intersection between two curves 3D

Post by rhum187 »

Hi everybody,

For several days I tried to find a way to put a red bullet at the intersection of two curves.
I put the code here.

Code: Select all

\documentclass{article}
\usepackage[utf8]{inputenc} 
\usepackage{fullpage}
\usepackage{tikz}
\usepackage{pgfplots}

\usetikzlibrary{calc,3d}

\begin{document}
\begin{tikzpicture}[scale=1.0,line/.style={ultra thick},
linedot/.style={dashed}]

\def\longueur{10}
\def\profondeur{4}
\def\hauteur{5}
\def\ecartement{5e-2}

\coordinate (B) at (\longueur,0,0);
\coordinate (G) at (\longueur,\hauteur,\profondeur);
\coordinate (M_bot) at (0,{\hauteur/2-\ecartement},0);
\coordinate (N_top) at (0,{\hauteur/2+\ecartement},\profondeur);

\draw[linedot] (M_bot) edge[out=359,in=140] (B);
\draw[line] (N_top) edge[out=1,in=220] (G);

\coordinate (cross) at (intersection of M_bot--B and N_top--G);
\fill[red] (cross) circle(5pt);

\end{tikzpicture}
\end{document}
Thanks in advance.
Romain.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Intersection between two curves 3D

Post by Stefan Kottwitz »

Hi Romain,

welcome to the forum!

I guess those one-dimensional curves don't intersect in 3D, it just looks like when you have the 2D view.

Here is a quick change of perspective.

Code: Select all

\documentclass{article}
\usepackage[utf8]{inputenc} 
\usepackage{fullpage}
\usepackage{tikz}
\usepackage{pgfplots}

\usetikzlibrary{calc,3d,intersections}
\usepackage{tikz-3dplot}

\begin{document}

\tdplotsetmaincoords{110}{60}
\begin{tikzpicture}[scale=1.0,line/.style={ultra thick},
linedot/.style={dashed},
tdplot_main_coords,
		axis/.style={->,blue,thick},
        grid/.style={very thin,gray}]

	%standard tikz coordinate definition using x, y, z coords
	\coordinate (O) at (0,0,0);
	
	%tikz-3dplot coordinate definition using r, theta, phi coords
	\tdplotsetcoord{P}{.8}{55}{60}
	
	%draw axes
	\draw[axis] (0,0,0) -- (10,0,0) node[anchor=north east]{$x$};
	\draw[axis] (0,0,0) -- (0,10,0) node[anchor=north west]{$y$};
	\draw[axis] (0,0,0) -- (0,0,10) node[anchor=south]{$z$};

	%draw a grid in the x-y plane
	\foreach \x in {-5,...,5}
		\foreach \y in {-5,...,5}
		{
			\draw[grid] (\x,-5) -- (\x,5);
			\draw[grid] (-5,\y) -- (5,\y);
		}			

\def\longueur{10}
\def\profondeur{4}
\def\hauteur{5}
\def\ecartement{5e-2}

\coordinate (B) at (\longueur,0,0);
\coordinate (G) at (\longueur,\hauteur,\profondeur);
\coordinate (M_bot) at (0,{\hauteur/2-\ecartement},0);
\coordinate (N_top) at (0,{\hauteur/2+\ecartement},\profondeur);

\draw[linedot] (M_bot) edge[out=359,in=140] (B);
\draw[line] (N_top) edge[out=1,in=220] (G);

%\coordinate[name intersections={of=one and two}] (cross) at (intersections-1);
%\fill[red] (cross) circle(5pt);

\end{tikzpicture}
\end{document}
intersection.png
intersection.png (17.16 KiB) Viewed 4178 times
Stefan
LaTeX.org admin
Post Reply