How can I draw a water lily in LaTeX?
You can use \clip
to cut away the outside parts, and use polar coordinates.
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[declare function={R=3;alpha=-20;},thick]
\draw circle[radius=R];
\clip circle[radius=R];
\draw foreach \X in {0,...,6}
{(alpha+60*\X:R) circle[radius=R]};
\end{tikzpicture}
\end{document}
Are you looking for this 5-petal "water-lily" ?
% a 5-petal rose (or "water-lily" if you like ^^)
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\def\R{3}
\draw (0,0) circle(\R);
\draw[smooth,magenta] plot[domain=0:36*5,samples=200] (\x:{\R*cos(5*\x)});
\end{tikzpicture}
\end{document}
I update the Asymptote version of @Jairo
//http://asymptote.ualberta.ca/
unitsize(3cm);
draw(unitcircle);
path petal=(1,0) .. (0,0) .. dir(144);
for(int i=1; i<=5; ++i) {draw(rotate(72*i+30)*petal,red);}
Using LuaTeX, it is easy to generate some more generic results.
\documentclass{article}
\usepackage{tikz}
\usepackage{luacode}
\begin{document}
\tikzset{
arcstyle/.style={
thick
}
}
\begin{luacode*}
one_degree = math.pi / 180
function get_inscribed_point(radius, n_poly, index, rotation)
local ang = (360.0 / n_poly * index + rotation) * one_degree
local x = radius * math.cos(ang)
local y = radius * math.sin(ang)
return {x,y}
end
function get_arc_info(p1, p2, p3)
local xa, ya = table.unpack(p1)
local xb, yb = table.unpack(p2)
local xc, yc = table.unpack(p3)
local coef1 = xb*xb - xc*xc + yb*yb - yc*yc
local coef2 = xa*xa - xb*xb + ya*ya - yb*yb
local coef3 = 2.0 * ((xa-xb)*(yb-yc)-(xb-xc)*(ya-yb))
-- calculate center
local center_x = (-(ya-yb)*coef1+(yb-yc)*coef2)/coef3
local center_y = ((xa-xb)*coef1-(xb-xc)*coef2)/coef3
-- calculate radius
local radius = math.sqrt(math.pow(xa-center_x, 2)+math.pow(ya-center_y, 2))
-- calculate arc angle range
local arc_ang1 = math.asin((0.5*math.sqrt(math.pow(xb-xa,2)+math.pow(yb-ya,2))/radius))
local arc_ang2 = math.asin((0.5*math.sqrt(math.pow(xc-xb,2)+math.pow(yc-yb,2))/radius))
local arc_angle = (arc_ang1 + arc_ang2) * 2.0
-- find out if (xc,yc) or (xa,ya) has the smallest angle
-- make sure xc has the smallest angle (if not, swap two points)
local ang_a = math.atan2(ya-center_y,xa-center_x)
local ang_c = math.atan2(yc-center_y,xc-center_x)
if ang_a < ang_c then
ang_a = ang_a + 2 * math.pi
end
-- determine start angle
local start_angle =ang_c
local end_angle = ang_a
-- return results
return {
["center_x"] = center_x,
["center_y"] = center_y,
["radius"] = radius,
["start_angle"] = start_angle / one_degree,
["end_angle"] = end_angle / one_degree,
["arc_start_x"] = xc,
["arc_start_y"] = yc
}
end
function draw_arc(p1, p2, p3)
local arc = get_arc_info(p1, p2, p3)
tex.print(string.format([[\draw[arcstyle] (%f cm, %f cm) arc (%f:%f:%f cm);]],
arc["arc_start_x"],
arc["arc_start_y"],
arc["start_angle"],
arc["end_angle"],
arc["radius"]))
end
function draw_lily(radius, n_poly, offset, rotation)
for i=1,n_poly do
local ind1 = i - 1
local ind2 = (i+offset - 1)%n_poly
local p1 = get_inscribed_point(radius, n_poly, ind1, rotation)
local p2 = {0.0,0.0}
local p3 = get_inscribed_point(radius, n_poly, ind2, rotation)
draw_arc(p1, p2, p3)
end
end
\end{luacode*}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\directlua{
draw_lily(2.0, 6, 2, 0.0)
}
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\directlua{
draw_lily(2.0, 6, 2, 15.0)
}
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\directlua{
draw_lily(2.0, 8, 2, 15.0)
}
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\directlua{
draw_lily(2.0, 12, 2, 15.0)
}
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\directlua{
draw_lily(2.0, 12, 3, 15.0)
}
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\directlua{
draw_lily(2.0, 12, 4, 15.0)
}
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\directlua{
draw_lily(2.0, 36, 2, 15.0)
}
\end{tikzpicture}
\end{document}