I am trying to use tikz to draw the red curve which should be at a constant distance from the blue part of the boundary of the domain. all I could do is to use coordinates but that's not accurate.
Is there any way to do this task, please? 
Asked
Active
Viewed 288 times
3
F.Marko
- 85
-
Just to note that drawing a curve parallel to a given curve is never going to be a straightforward task because a parallel of a bézier curve is not, in general, a bézier curve. So there are "tricks", such as those already suggested or using a decoration, but it will never be quite as straightforward as drawing the original curve. – Andrew Stacey Jun 05 '22 at 11:46
-
1@AndrewStacey Some 40 years ago when I was at the GE research department we tried to get accurate offsets of Bezier curves but in general the offset is not a Bezier curve. We never resolved the problem but kept taking offset points from the curve and then use these as input to a further set of curves (original to several connected) curves until the result was "good enough". The application was generating tool paths for machining curved surfaces on metal parts. – Peter Wilson Jun 05 '22 at 17:23
-
I think here is one way https://tex.stackexchange.com/a/580768/140722 – Black Mild Sep 08 '22 at 20:26
2 Answers
4
You can use a double line and a clip if you don't mind having a white filling.
For example:
\documentclass[tikz,border=2mm]{standalone}
\newcommand{\kidneyA}
{
(2.1,1.5) to[out=100,in=0] (0.3,3) to[out=180,in=90] (-0.5,2) to[out=270,in=90] (-0.3,0.4)
to[out=270,in=35] (-1.4,-1) to[out=215,in=90] (-2.7,-2.7) to[out=270,in=215] (-0.1,-2.8)
}
\newcommand{\kidneyB}{(-0.1,-2.8) to [out=35,in=280] (2.1,1.5)}
\begin{document}
\begin{tikzpicture}[line join=round,line cap=round]
\begin{scope}
\clip \kidneyA \kidneyB;
\draw[red,ultra thick,double,double distance=6mm] \kidneyB;
\end{scope}
\draw \kidneyA;
\draw[blue,ultra thick] \kidneyB;
\end{tikzpicture}
\end{document}
Juan Castaño
- 28,426
4
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{hobby}
\begin{document}
\begin{tikzpicture}[very thick, use Hobby shortcut]
\begin{scope}
\clip[closed] (0,0)..(-1,1)..(1,3)..(1.5,5)..(3,4)..(1.5,0.5);
\draw[red, line cap=round, double, double distance=1cm, closed] ([blank=soft]0,0)..([blank=soft]-1,1)..([blank=soft]1,3)..([blank=soft]1.5,5)..([blank=soft]3,4)..(1.5,0.5);
\end{scope}
\draw[closed] (0,0)..(-1,1)..(1,3)..(1.5,5)..(3,4)..(1.5,0.5);
\draw[cyan, closed] ([blank=soft]0,0)..([blank=soft]-1,1)..([blank=soft]1,3)..([blank=soft]1.5,5)..([blank=soft]3,4)..(1.5,0.5);
\end{tikzpicture}
\end{document}
hpekristiansen
- 37,006

