Tutorials

Minimizing the length of a loop, part 1: Creating the loop

In our very first sequence of Morpho tutorials, we’re going to consider perhaps the most basic example of shape minimization possible: a loop. The problem is to minimize the length of a loop subject to the constraint that the area enclosed by the loop remains constant. The solution is well known: the answer is a circle. As we’ll see in later posts, even this very simple problem has some pathological features, particularly if we start the loop from an initial shape that is very far from circular.

In this post, we will being by creating the loop. Morpho includes several ways to do this: we could load it from a file, or construct it using one of several built in functions. Here, we’ll use the manifoldline function, which builds a manifold from a parametric expression. If you type,

[code gutter=”false” lang=”js”]m=manifoldline({cos(t), sin(t),0}, {t,0,2*pi, 0.1}, closed=true)[/code]

into Morpho, you should get the response

<body>

which tells you Morpho successfully created the shape. To see what it looks like, type

[code gutter=”false” lang=”js”]show(m)[/code]

after which a separate window should open with your loop visible:

Clearly, our call to manifoldline created a circular loop. This is because the statement

[code gutter=”false” lang=”js”]m=manifoldline({cos(t), sin(t),0}, {t,0,2*pi, 0.1}, closed=true)[/code]

means “sweep out the parameter t from 0 to 2π in steps of 0.1, generating points with coordinates {cos(t), sin(t), 0} at each value of t“. The option closed=true tells manifoldline to close the loop at the end.

To make a more interesting loop, we can modify the parametric expression passed to manifoldload. For example, try entering the following

[code gutter=”false” lang=”js”]np=20
A=0.5
m=manifoldline({(1+A*cos(4*t))*cos(t), (1+A*cos(4*t))*sin(t),0}, {t,0,2*pi-pi/np/2, pi/np}, closed=true)[/code]

and visualize the result with

[code gutter=”false” lang=”js”]show(m)[/code]

as before. You’ll now see the shape below, noting that you may need to use the scroll wheel on your mouse or slide with two fingers on your trackpad to zoom out slightly.

In the second part of this tutorial, we’ll tell Morpho that we want to minimize the length of this loop and see how to get it to do so.

 

Leave a Reply