Today is Valentine's Day. So, we are going to draw some hearts, and then send them all to our lovers. Of course, we are going to do it by coding and math. This is what we are going to accomplish today: The outline of a heart is a path of points \((x,y)\), which are given by the following parametric equations: $$ \begin{align} x&=x_c+16\sin(t)^3,\\ y&=y_c+13\cos(t)-5\cos(2t)\\ &\quad\quad\quad-2\cos(3t)-\cos(4t), \end{align} $$ for \(-\pi\leq t\leq \pi\). Here, \((x_c,y_c)\) is the center of the heart. You can change the location of the heart by changing \((x_c,y_c)\). We implement the above parametric equations in SIMO or Console as a function like the following one: aheart.m
Now, you can run the function above with center \((0,0)\) to produce the following heart. This heart has only 30 path points, and therefore is not very smooth. You can make it smoother by increasing the number of path points. Next, we need to duplicate this heart many times with different centers \((x_c,y_c)\). The centers are in fact path points on a bigger heart. The first part of the following code generates path points of the bigger heart. We need to scale it up 10 times bigger than the normal heart. These path points will serve as the centers of the smaller hearts, which will be drawn in the for-loop. It loops through each of the path points of the bigger hearts, and each of them is the center point of a smaller heart. manyhearts.m
If you run the above script, you will get the following:. Finally, you can save the plot as an image using the export feature of the app. Then, you can find the saved picture in the Photos app on your iPhone or iPad. You may want to do some editing like cropping and filters. Finally, you can send it to your lover! Happy Valentine's Day!
1 Comment
12/24/2022 11:20:37
terima kasih atas infonya salam kenal <a href="https://kwikprintsurabaya.com">DIGITAL PRINTING DAN CETAK DIGITAL TERDEKAT DI SURABAYA</a>
Reply
Leave a Reply. |
Mark Lau
SIMO Developer Archives |