So zeichnen Sie die Kleeblattkurve mit Tikz

So zeichnen Sie die Kleeblattkurve mit Tikz

Ich muss mit Tikz eine geschlossene Kurve der folgenden Form zeichnen, Bildbeschreibung hier eingeben

das ist so etwas wie ein Kleeblattknoten, der in eine Ebene gedrückt, aber auch gedreht ist. Ich habe mich gefragt, ob es dazu Hilfe oder Vorschläge geben könnte. Vielen Dank im Voraus.

Antwort1

Bildbeschreibung hier eingeben

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

 \begin{tikzpicture}[scale=0.7]
\draw[line width=0.3mm, -stealth] (0,-4)--(0,4);
\draw[line width=0.3mm, -stealth] (-4,0)--(4,0);
\draw[-stealth, domain=0:540, variable=\t,samples=200, line width=0.7mm]
plot ({-cos(\t)+2*cos(2*\t)}, {sin(\t)+2*sin(2*\t)});
\draw[fill=white, line width=0.5mm] (0,0) circle[radius=0.25 em];
\draw[fill=white, line width=0.5mm] (2,0) circle[radius=0.25 em];
\draw(-0.3,-0.1) node[below]{$0$};
\draw(2,0.1) node[above]{$1$};
\end{tikzpicture}
\end{document}

Antwort2

\documentclass{standalone} 
\usepackage{tkz-fct}

\begin{document} 
 \begin{tikzpicture}
   \tkzInit[xmin=-4,xmax=4,ymin=-4,ymax=4,xstep=.2,ystep=.2]
   \tkzFctPar[samples=400,domain=-pi:pi]{-cos(t)+2*cos(2*t)}{sin(t)+2*sin(2*t)}
 \end{tikzpicture}
\end{document}

Bildbeschreibung hier eingeben

Antwort3

Ich habe es auf zwei Arten gemacht, aber ich glaube, die zweite kommt dem, was Sie suchen, am nächsten.

Bildbeschreibung hier eingeben

\documentclass{standalone}
\usepackage{tikz}
\usepackage{xcolor}
\definecolor{sidecolor}{HTML}{E7E7E7}

\begin{document}

\begin{tikzpicture}[very thick]
\draw[gray!30] (-2,-2) grid (2,2);

\draw (1.3,0) .. controls (1,0.8) and (0,0.5) .. (-0.5,0);
\draw[cm={1,0,0,-1,(0,0)}] (1.3,0) .. controls (1,0.8) and (0,0.5) .. (-0.5,0);
\draw[rotate=120] (1.3,0) .. controls (1,0.8) and (0,0.5) .. (-0.5,0);
\draw[cm={1,0,0,-1,(0,0)},rotate=240] (1.3,0) .. controls (1,0.8) and (0,0.5) .. (-0.5,0);
\draw[rotate=240] (1.3,0) .. controls (1,0.8) and (0,0.5) .. (-0.5,0);
\draw[cm={1,0,0,-1,(0,0)},rotate=120] (1.3,0) .. controls (1,0.8) and (0,0.5) .. (-0.5,0);

\end{tikzpicture}

\begin{tikzpicture}[very thick]
\draw[gray!30] (-2,-2) grid (2,2);

\draw (1.3,0) to[out=90,in=60] (-0.5,0);
\draw[cm={1,0,0,-1,(0,0)}] (1.3,0) to[out=90,in=60] (-0.5,0);
\draw[rotate=120] (1.3,0) to[out=90,in=60] (-0.5,0);
\draw[cm={1,0,0,-1,(0,0)},rotate=240] (1.3,0) to[out=90,in=60] (-0.5,0);
\draw[rotate=240] (1.3,0) to[out=90,in=60] (-0.5,0);
\draw[cm={1,0,0,-1,(0,0)},rotate=120] (1.3,0) to[out=90,in=60] (-0.5,0);

\end{tikzpicture}

\end{document}

Antwort4

Eine SkiaSharp-Lösung nur zum Spaß! Wir können das Folgende kompilieren, um \immediate\write18es TeX-bezogener zu machen.

using CSharpMath.SkiaSharp;
using SkiaSharp;
using System.Diagnostics;
using static System.MathF;

class Diagram
{
    const float scale = SKDocument.DefaultRasterDpi / 2.54f; // dots per cm

    static float PtToCm(float pt) => pt / scale;

    static readonly SKPaint strokeBlack = new SKPaint
    {
        Style = SKPaintStyle.Stroke,
        StrokeWidth = PtToCm(0.8f),
        Color = SKColors.Black,
        StrokeCap = SKStrokeCap.Round,
        IsAntialias = true
    };

    static readonly SKPaint strokeRed = new SKPaint
    {
        Style = SKPaintStyle.Stroke,
        StrokeWidth = PtToCm(0.8f),
        Color = SKColors.Red,
        StrokeCap = SKStrokeCap.Round,
        IsAntialias = true
    };


    static readonly SKPaint fillGreen = new SKPaint
    {
        Style = SKPaintStyle.Fill,
        StrokeWidth = PtToCm(0.8f),
        Color = SKColors.Green,
        StrokeCap = SKStrokeCap.Round,
        IsAntialias = true
    };

    static readonly SKRect domain = new SKRect(-5f, 5f, 5f, -5f);

    static readonly float width = domain.Width * scale;
    static readonly float height = -domain.Height * scale;


    public static void Generate(string filename)
    {
        using (var stream = new SKFileWStream($"{filename}.pdf"))
        using (var document = SKDocument.CreatePdf(stream))
        using (var canvas = document.BeginPage(width, height))
        {
            canvas.Scale(scale, -scale);
            canvas.Translate(-domain.Left, -domain.Top);

            canvas.DrawLine(domain.Left + 0.5f, 0, domain.Right - 0.5f, 0, strokeBlack);
            canvas.DrawLine(0, domain.Bottom + 0.5f, 0, domain.Top - 0.5f, strokeBlack);

            int N = 100;
            int start = 0; // degrees
            int stop = 360; // degrees
            float d = (stop - start) * PI / (180 * N);

            SKPoint[] pts = Enumerable
                                .Range(0, N)
                                .Select(i => new SKPoint
                                {
                                    X = -Cos(i * d) + 2 * Cos(2 * i * d),
                                    Y = Sin(i * d) + 2 * Sin(2 * i * d)
                                })
                                .ToArray();

            for (int i = 0; i < N; ++i)
                canvas.DrawLine(pts[i], pts[(i + 1) % N], strokeRed);

            canvas.DrawCircle(1, 0, PtToCm(2), fillGreen);

            MathPainterExtension.Painter.FontSize = PtToCm(12);
            canvas.Draw("1", 1.3f, PtToCm(10));

            MathPainterExtension.Painter.FontSize = PtToCm(8);
            canvas.Draw(@"\begin{cases} x(t) = -\cos t + 2 \cos (2t) \\ y(t) = \sin t + 2 \sin (2t) \end{cases}", 2.5f, 4);
            document.EndPage();
        }
    }

Bildbeschreibung hier eingeben

verwandte Informationen