Loading editor...

Cardioid

Loading commands, almost done…

Copying the definition from Wikipedia, a Cardioid is a plane curve traced by a point on the perimeter of a circle that is rolling around a fixed circle of the same radius. In this canvas, we want to show that it is the envelope of a family of circles. Each circle has its center one the perimeter of the fixed circle and its radius is the distance from its center to the starting point of the curve.

Using the power of broadcasting, one can see how easy it is to visualize it. We start with a family of six circles first:

  • : n = \scalar 6

These commands do not have any visual effect on the canvas.

  • : n-minus-one = \sub n 1
  • : nums = \linspace 0 n-minus-one n
  • : fractions = \div nums n
  • : degrees = \mul 360 fractions
  • : radians = \deg2rad degrees
  • : r = \scalar 2
  • : cos = \cos radians
  • : sin = \sin radians
  • : rcos = \mul r cos
  • : rsin = \mul r sin

Create points on circle

Up until this point, running the above commands will not show anything on the canvas. To see the points on the circle, we need to create the points and draw the circles:

  • : points = \point rcos rsin

Since these points belong to an array, you can simply by highlighting the array name points.

We want to calculate the distances of each of these points from .

Note how broadcasting allows us to calculate the distances for each point on the circle ...

  • : dists = \distance points p1

... and then draw circles for each point and distance:

  • : \circle points dists

Now the envelope may not be obvious. To make it more obvious, let's increase the number of points.

First, let's create an array to control the number of points:

  • : ns = \array 10 12 15 18 20 25

Use the slider below to adjust the value of n and see how the cardioid emerges:

Run the \cardioid command in the geomatic editor and modify the variables to play with it.