 Function Repository Resource:

LevyCCurve

Generate the Lévy C curve

Contributed by: Sander Huisman
 ResourceFunction["LevyCCurve"][n] generates the line segments of the Lévy C curve with n iterations. ResourceFunction["LevyCCurve"][{p1,p2},n] uses the line connecting the points p1 and p2 as the initial line. ResourceFunction["LevyCCurve"][{p1,p2,… ,pn},n] uses the lines joining the points pi.

Details

The following transformation is done with each line segment: The first 4 iterations and the 9th iteration: ResourceFunction["LevyCCurve"][n] is equivalent to ResourceFunction["LevyCCurve"][{{-1,0},{1,0}},n].
The syntax ResourceFunction["LevyCCurve"][Line[{p1,p2, ,pn}],n] is also supported.

Examples

Basic Examples (2)

Generate the Lévy C curve for 4 iterations:

 In:= Out= Generate the line for 8 iterations and visualize the result:

 In:= Out= Scope (1)

Start from a vertical line segment:

 In:= Out= Properties and Relations (1)

The length of the Lévy C curve grows approximately exponentially:

 In:= Out= Neat Examples (2)

"Inwards" and "outwards" Lévy C curve starting from a square:

 In:= Out= Color the curve along its length:

 In:= Out= Author Notes

Code used for images in the Details & Option section:

Graphics[{Text[Style["",14],{0,1/2}],RGBColor[0.`,0.`,0.5`],Translate[LevyCCurve,{-1.5,0}],Translate[LevyCCurve,{1.5,0}]},ImageSize200] Table[{Framed[Graphics[{RGBColor[0.`,0.`,0.5`],LevyCCurve[n]},ImageSize{80,60}],FrameStyle Directive[GrayLevel[0.75], Thickness[Tiny]]],Row[{Style["n", FontFamily "Times", FontSize 10, FontSlant Italic],Style[" = "<>ToString[n], FontFamily "Helvetica", FontSize 10]}]},{n,{0,1,2,3,4,9}}]//Transpose//Grid 