Graphics, Figures & TablesDrawing interlocking tori using sketch/tikz

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
moitetajni
Posts: 2
Joined: Tue Aug 25, 2015 11:03 pm

Drawing interlocking tori using sketch/tikz

Post by moitetajni »

Hello.

I am trying to create the graph of some interlocking tori like these two
interlocking_tori2.png
interlocking_tori2.png (39.63 KiB) Viewed 3846 times
Since I am not an expert on tikz or sketch, I have been modifying some code I found on the web. So here's the code I have been running so far:

Code: Select all

def torus {
    def n_segs 60
    sweep [draw=none, fill=cyan, fill opacity=0.75] {n_segs, rotate(360/n_segs, (0,0,0), [0,1,0])}
        sweep {n_segs, rotate(360/n_segs, (1.5,0,0), [0,0,1])}
        (2,0,0)
}

def torus2 {
	def n_segs 60
	sweep [draw=none, fill=orange, fill opacity=0.75] {n_segs, rotate(360/n_segs, (1.5,0,0), [0,0,1]) }
		sweep {n_segs, rotate(360/n_segs, (0,0,0), [0,1,0])}
		(2,0,0)

}

put { view((10,4,2)) } {{torus2} {torus}}

global { language tikz }
Here, torus2 was the code I created based on torus. However it is not doing the trick, since I I get is this mess:
failed_interlocking_tori.png
failed_interlocking_tori.png (87.02 KiB) Viewed 3846 times
So my question would be: how can I redefine torus2 so the whole image looks like the one I want?

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Drawing interlocking tori using sketch/tikz

Post by Stefan Kottwitz »

Welcome to the forum!

So what did you use - Sketch?

I could imagine making it using pgfplots, which bases on TikZ. Such as this example from TeXwelt, by Henri and Ross:

Code: Select all

\documentclass[margin=2mm,tikz]{standalone}
\usepackage{pgfplots}
\begin{document}
%Oberflächenproblem
\begin{tikzpicture}[line width=.7pt]
\begin{axis}[axis equal image,
    clip=false,
    xlabel=\empty, ylabel=\empty, zlabel=\empty,
    axis lines=middle,
    colormap/blackwhite,
    %y dir=reverse,
    %axis on top
    ]
    % sym. Torus:
            \addplot3[domain=0:360,y domain=0:360, samples=50,
            surf,z buffer=sort
            ]
            ({15+(10+4*cos(x))*cos(y)} ,
            {15+(10+4*cos(x))*sin(y)},
            {4+4*sin(x)});
\end{axis}
\end{tikzpicture} 
\end{document}
torus.png
torus.png (60.05 KiB) Viewed 3839 times
Two tori may be split in parts and drawn in an order so the back would be behind the front.

Stefan
LaTeX.org admin
Post Reply