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 6These commands do not have any visual effect on the canvas.
n-minus-one = \sub n 1nums = \linspace 0 n-minus-one nfractions = \div nums ndegrees = \mul 360 fractionsradians = \deg2rad degreesr = \scalar 2cos = \cos radianssin = \sin radiansrcos = \mul r cosrsin = \mul r sinUp 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 rsinSince 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 distsNow 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 25Use 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.