Function Repository Resource:

CurvaturePlot

Source Notebook

Plot a curve defined by its curvature

Contributed by: Sander Huisman

ResourceFunction["CurvaturePlot"][f,{t,tmin,tmax}]

plots the curve defined by its curvature f as a function of t.

ResourceFunction["CurvaturePlot"][{f1,f2,},{t,tmin,tmax}]

plots several curves defined by their curvatures fi.

ResourceFunction["CurvaturePlot"][,{t,tmin,tmax},{{x0,y0},θ0}]

starts the curves at {x0,y0} in the direction θ0.

Details and Options

The default starting location is at {0,0} and in the direction θ0=0. The angle θ0 is defined as follows:
A constant curvature c draws a circle with radius 1/c.
ResourceFunction["CurvaturePlot"] has the same options as ParametricPlot and NDSolve.

Examples

Basic Examples (3) 

Plot a curve with increasing curvature:

In[1]:=
ResourceFunction["CurvaturePlot"][t, {t, 0, 7.5}]
Out[1]=

Plot a curve with a sinusoidally varying curvature:

In[2]:=
ResourceFunction["CurvaturePlot"][3.5 Sin[t], {t, 0, 8 Pi}]
Out[2]=

Plot multiple curves:

In[3]:=
ResourceFunction["CurvaturePlot"][{Sin[t] t, Cos[t] t}, {t, 0, 30}]
Out[3]=

Scope (1) 

Start at the point {5,7} in the left direction:

In[4]:=
ResourceFunction["CurvaturePlot"][
 Cos[u] + 0.03 u, {u, 0, 75}, {{5, 7}, Pi}]
Out[4]=

Options (34) 

AspectRatio (2) 

By default, the AspectRatio comes from PlotRange:

In[5]:=
ResourceFunction["CurvaturePlot"][0.6 Pi Cos[t], {t, 0, 8 Pi}]
Out[5]=

Set a different AspectRatio:

In[6]:=
ResourceFunction["CurvaturePlot"][0.6 Pi Cos[t], {t, 0, 8 Pi}, AspectRatio -> 1/GoldenRatio]
Out[6]=

Axes (1) 

Draw no axes:

In[7]:=
ResourceFunction["CurvaturePlot"][
 2 (Sin[t] + Sin[Sqrt[3] t]) + 0.05, {t, 0, 200}, Axes -> False]
Out[7]=

AxesLabel (1) 

Specify labels for the x- and y-axes:

In[8]:=
ResourceFunction["CurvaturePlot"][
 Sin[t] + 4 Sin[Sqrt[2] t], {t, 0, 20 Pi}, AxesLabel -> {x, y}]
Out[8]=

AxesOrigin (2) 

Determine where the axes cross automatically:

In[9]:=
ResourceFunction["CurvaturePlot"][1, {t, 0, 2 Pi}, {{10, 5}, 0}, AxesOrigin -> Automatic]
Out[9]=

Specify the axes origin at the point {0,0}:

In[10]:=
ResourceFunction["CurvaturePlot"][1, {t, 0, 2 Pi}, {{10, 5}, 0}, AxesOrigin -> {0, 0}]
Out[10]=

ColorFunction (5) 

Color the curve by scaled x-, y- or t-values:

In[11]:=
Table[ResourceFunction["CurvaturePlot"][1, {t, 0, 2 Pi}, ColorFunction -> Function[{x, y, t}, i], PlotLabel -> i, PlotStyle -> Thick], {i, {Hue[x], Hue[y], Hue[t]}}]
Out[11]=

Use a named color gradient:

In[12]:=
ResourceFunction["CurvaturePlot"][1, {t, 0, 2 Pi}, ColorFunction -> "Rainbow"]
Out[12]=

ColorFunction has higher priority than PlotStyle:

In[13]:=
ResourceFunction["CurvaturePlot"][1, {t, 0, 2 Pi}, ColorFunction -> "Rainbow", PlotStyle -> Directive[Red, Thick]]
Out[13]=

Use red for the parameter t>2π:

In[14]:=
ResourceFunction["CurvaturePlot"][Sin[t], {t, 0, 4 Pi}, ColorFunction -> Function[{x, y, t}, If[t > 2 Pi, Red, Black]], ColorFunctionScaling -> False, PlotStyle -> Thick]
Out[14]=

Color by the absolute curvature:

In[15]:=
ResourceFunction["CurvaturePlot"][
 0.65 Pi Cos[t], {t, 0, 8 Pi}, {{10, 10}, Pi/4}, PlotRange -> All, ImageSize -> 350, ColorFunction -> Function[{x, y, t}, ColorData[{"Rainbow", {0, 0.65 Pi}}][0.65 Pi Abs@Cos[t]]], ColorFunctionScaling -> False]
Out[15]=

ColorFunctionScaling (1) 

Color the curve by the phase of the sine:

In[16]:=
ResourceFunction["CurvaturePlot"][6 Sin[2 Pi t], {t, 0, 3}, PlotStyle -> Thick, ColorFunction -> Function[{x, y, u}, Hue[u]], ColorFunctionScaling -> False]
Out[16]=

MaxRecursion (1) 

Each level of MaxRecursion will adaptively subdivide the initial mesh into a finer mesh:

In[17]:=
Table[ResourceFunction["CurvaturePlot"][6 Sin[2 Pi t], {t, 0, 3}, MaxRecursion -> i, PlotPoints -> 15, Mesh -> All], {i, 0, 2}]
Out[17]=

Mesh (1) 

Show the initial and final sampling meshes:

In[18]:=
{ResourceFunction["CurvaturePlot"][6 Sin[2 Pi t], {t, 0, 3}, Mesh -> Full], ResourceFunction["CurvaturePlot"][6 Sin[2 Pi t], {t, 0, 3}, Mesh -> All]}
Out[18]=

PerformanceGoal (2) 

Generate a higher-quality plot:

In[19]:=
Timing[ResourceFunction["CurvaturePlot"][6 Sin[2 Pi t], {t, 0, 3}, PerformanceGoal -> "Quality"]]
Out[19]=

Emphasize performance, possibly at the cost of quality:

In[20]:=
Timing[ResourceFunction["CurvaturePlot"][6 Sin[2 Pi t], {t, 0, 3}, PerformanceGoal -> "Speed"]]
Out[20]=

PlotLabels (5) 

Specify the text to label the curves:

In[21]:=
ResourceFunction["CurvaturePlot"][{Sin[t] t, Cos[t] t}, {t, 0, 30}, PlotLabels -> {"Label 1", "Label 2"}]
Out[21]=

Place the labels above the curves:

In[22]:=
ResourceFunction["CurvaturePlot"][{Sin[t] t, Cos[t] t}, {t, 0, 30}, PlotLabels -> Placed[{"label1", "label2"}, Above]]
Out[22]=

Place the labels differently for each curve:

In[23]:=
ResourceFunction["CurvaturePlot"][{Sin[t] t, Cos[t] t}, {t, 0, 30}, PlotLabels -> {Placed["label1", Above], Placed["label2", Below]}, Axes -> False]
Out[23]=

Use callouts to identify the curves:

In[24]:=
ResourceFunction["CurvaturePlot"][{Sin[t] t, Cos[t] t}, {t, 0, 30}, PlotLabels -> {Callout["label1", {Scaled[0.5], Above}], Callout["label2", {Scaled[0.5], Below}]}]
Out[24]=

Put labels relative to the outside of the curves:

In[25]:=
Table[ResourceFunction[
  "CurvaturePlot"][{Sin[t] t, Cos[t] t}, {t, 0, 30}, PlotLabels -> Callout[{"label1", "label2"}, pos]], {pos, {After, Before}}]
Out[25]=

Use None to not add a label:

In[26]:=
ResourceFunction["CurvaturePlot"][{Sin[t] t, Cos[t] t}, {t, 0, 30}, PlotLabels -> {None, "label2"}]
Out[26]=

PlotLegends (5) 

No legends are used by default:

In[27]:=
ResourceFunction["CurvaturePlot"][Sin[t], {t, 0, 2 Pi}]
Out[27]=

Create a legend with specific labels:

In[28]:=
ResourceFunction["CurvaturePlot"][Sin[t], {t, 0, 2 Pi}, PlotLegends -> {"one"}]
Out[28]=

PlotLegends picks up PlotStyle values automatically:

In[29]:=
ResourceFunction["CurvaturePlot"][{Sin[t], Cos[t]}, {t, 0, 2 Pi}, PlotStyle -> {Red, Blue}, PlotLegends -> Automatic]
Out[29]=

Use Placed to position legends:

In[30]:=
ResourceFunction["CurvaturePlot"][{Sin[t], Cos[t]}, {t, 0, 2 Pi}, PlotStyle -> {Red, Blue}, PlotLegends -> Placed[Automatic, Below]]
Out[30]=

Place legends inside:

In[31]:=
ResourceFunction["CurvaturePlot"][{Sin[t], Cos[t]}, {t, 0, 2 Pi}, PlotStyle -> {Red, Blue}, PlotLegends -> Placed[Automatic, {0.65, 0.65}], Axes -> False]
Out[31]=

Use LineLegend to modify the appearance of the legend:

In[32]:=
ResourceFunction["CurvaturePlot"][{Sin[t], Cos[t]}, {t, 0, 2 Pi}, PlotLegends -> LineLegend[{"1", "2"}, LegendFunction -> Frame]]
Out[32]=

PlotPoints (1) 

Use more initial points to get a smoother plot:

In[33]:=
Table[ResourceFunction["CurvaturePlot"][Sin[t], {t, 0, 4 Pi}, PlotPoints -> i, MaxRecursion -> 0], {i, {10, 15, 25, 50}}]
Out[33]=

PlotRange (1) 

Change the PlotRange:

In[34]:=
ResourceFunction["CurvaturePlot"][3 Cos[t], {t, 0, 4 Pi}, PlotRange -> {{-5, 1}, {-0.5, 2}}]
Out[34]=

PlotStyle (3) 

Use different style directives:

In[35]:=
Table[ResourceFunction["CurvaturePlot"][5 Cos[t], {t, 0, 4 Pi}, PlotStyle -> ps, Axes -> False], {ps, {Red, Thick, Dashed, Directive[Purple, Thick]}}]
Out[35]=

By default, different styles are chosen for multiple curves:

In[36]:=
ResourceFunction["CurvaturePlot"][{3 Cos[t], -3 Cos[t]}, {t, 0, 4 Pi}]
Out[36]=

Explicitly specify the style for different curves:

In[37]:=
ResourceFunction["CurvaturePlot"][{3 Cos[t], -3 Cos[t]}, {t, 0, 4 Pi},
  PlotStyle -> {Red, Blue}]
Out[37]=

PlotTheme (1) 

Use a marketing theme:

In[38]:=
ResourceFunction["CurvaturePlot"][{3 Cos[t], -3 Cos[t]}, {t, 0, 4 Pi},
  PlotTheme -> "Marketing"]
Out[38]=

WorkingPrecision (2) 

Evaluate functions using machine-precision arithmetic:

In[39]:=
ResourceFunction["CurvaturePlot"][5 Sin[t + 10^20]/2, {t, 0, 4 Pi}, WorkingPrecision -> MachinePrecision]
Out[39]=

Evaluate functions using arbitrary-precision arithmetic:

In[40]:=
ResourceFunction["CurvaturePlot"][5 Sin[t + 10^20]/2, {t, 0, 4 Pi}, WorkingPrecision -> 30]
Out[40]=

Possible Issues (2) 

More steps may be needed in the integration:

In[41]:=
ResourceFunction["CurvaturePlot"][Exp[t], {t, 0, 14}, PlotPoints -> 1000, PlotRange -> {{0, 1}, {0, 1}}]
Out[41]=

Supply a larger MaxSteps option:

In[42]:=
ResourceFunction["CurvaturePlot"][Exp[t], {t, 0, 14}, MaxSteps -> \[Infinity], PlotPoints -> 1000, PlotRange -> {{0, 1}, {0, 1}}]
Out[42]=

Neat Examples (4) 

Plot an increasingly-curvy curve:

In[43]:=
ResourceFunction["CurvaturePlot"][Cos[t] t, {t, 0, 100}]
Out[43]=

Elementary function can lead to very complicated patterns:

In[44]:=
ResourceFunction[
 "CurvaturePlot"][(SawtoothWave[t] - 1/2) Sin[t] 70 + 0.03, {t, 0, 200}]
Out[44]=

Plot a bunch of connected circles:

In[45]:=
ResourceFunction["CurvaturePlot"][5 \[Pi] SquareWave[t], {t, 0, 10}]
Out[45]=

Create intricate non-repeating patterns:

In[46]:=
ResourceFunction[
 "CurvaturePlot"][(SawtoothWave[t] - 1/2) Sin[t] 65, {t, 0, 100}, Axes -> False, ImageSize -> 600]
Out[46]=

Publisher

SHuisman

Version History

  • 1.0.0 – 26 July 2019

Related Resources

License Information