Graphics, Figures & Tables ⇒ tikZ | Quadratic Bézier Curves
tikZ | Quadratic Bézier Curves
TikZ only provides support for cubic Bézier curves, which is one too much for me.
Failing that, does anyone know how to convert a cubic Bézier curve into a quadratic one?
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
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
tikZ | Quadratic Bézier Curves
Code: Select all
Q0 = P0
Q1 = 1/3 P0 + 2/3 P1
Q2 = 2/3 P1 + 1/3 P2
Q3 = P2
Code: Select all
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (0,0) grid (3,1);
\filldraw [gray] (0,0) circle (2pt)
(2,1) circle (2pt)
(3,0) circle (2pt);
\draw (0,0) .. controls (1.334,0.667) and (2.334,0.667) .. (3,0);
\end{tikzpicture}
\end{document}
Best regards and welcome to the board
Thorsten¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: tikZ | Quadratic Bézier Curves
a 1d explicit quadratic bezier function looks like this:
y = A*(1-x)^2 + B*2x(1-x) + C*x^2
I just did that to get a 1d bezier curve diagram for my paper. Not sure if tikZ can plot multi-dimensional functions or not where f(x,y)=0, but if so, you just have one of those explicit 1d bezier curves per axis, where A,B,C are the control points for that specific axis.
If it helps, here's how to draw a 1d quadratic bezier curve with control points 0,1,0
\draw[scale=1,domain=0:1,smooth,variable=\x,blue] plot ({\x},{2*\x-2*\x*\x});