{"id":7328,"date":"2023-10-31T06:38:08","date_gmt":"2023-10-31T06:38:08","guid":{"rendered":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/?p=7328"},"modified":"2023-11-02T02:51:52","modified_gmt":"2023-11-02T02:51:52","slug":"polar-curve-and-parametric-curve-for-the-g-code","status":"publish","type":"post","link":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/2023\/10\/31\/polar-curve-and-parametric-curve-for-the-g-code\/","title":{"rendered":"polar curve and parametric curve for the g-code"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">When I was in high school, polar curve is one of my favorite math subject. So I decided to use some concepts from the polar curve to finish this project. I will do the project based on three polar curves: spiral curve, rose curve, and heart shape curve.  The major philosophy behind this is to define R and theta, then find the x y value based on them. In order to make things more interesting, some of the z values are the function of x and y.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The first curve I tried is the spiral curve, r = theta; this one is easy:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"395\" height=\"399\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-74.png\" alt=\"\" class=\"wp-image-7367\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-74.png 395w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-74-297x300.png 297w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-74-380x384.png 380w\" sizes=\"auto, (max-width: 395px) 100vw, 395px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1024x768.jpg\" alt=\"\" class=\"wp-image-7358\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1024x768.jpg 1024w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-300x225.jpg 300w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-768x576.jpg 768w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1536x1152.jpg 1536w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1140x855.jpg 1140w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-920x690.jpg 920w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-575x431.jpg 575w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-380x285.jpg 380w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image.jpg 1702w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To add some flavors to this simple shape, I make the z value as a function of x and y; to be specifically z = Zmax*(1-(x^2+y^2)\/(x_max^2+y_max^2)); this can add a weight to the z value, when x and y values are small, z will be larger\/taller. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"370\" height=\"339\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-76.png\" alt=\"\" class=\"wp-image-7382\" style=\"aspect-ratio:1.0914454277286136;width:468px;height:auto\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-76.png 370w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-76-300x275.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"465\" height=\"472\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-77.png\" alt=\"\" class=\"wp-image-7383\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-77.png 465w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-77-296x300.png 296w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-77-380x386.png 380w\" sizes=\"auto, (max-width: 465px) 100vw, 465px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1-1024x576.jpg\" alt=\"\" class=\"wp-image-7384\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1-1024x576.jpg 1024w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1-300x169.jpg 300w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1-768x432.jpg 768w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1-1536x864.jpg 1536w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1-1140x641.jpg 1140w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1-920x518.jpg 920w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1-575x323.jpg 575w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1-380x214.jpg 380w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-1.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This is harder to print out, I tried different parameters such as the extruder width and speed. But the result is still not   ideal. I will try this again using broader width. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The next curve I tried is the heart curve, but I tried the polar curve of r = a+bcos(theta); but no matter how I tune the a and b values, the shape is not exactly what we need. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"383\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-78.png\" alt=\"\" class=\"wp-image-7385\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-78.png 975w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-78-300x118.png 300w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-78-768x302.png 768w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-78-920x361.png 920w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-78-575x226.png 575w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-78-380x149.png 380w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So I turned into parametric equations to draw a better heart shape curve. Like this one:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"238\" height=\"212\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-79.png\" alt=\"\" class=\"wp-image-7386\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">What I tried is to use the neural network method to try different combinations of the trigonometric function order,  phase, and magnitude. It will take a long time if we use brutal force approach. I manually developed a neural network for it. The learning rate of the neural network is set to 1 since I want all of these parameters to be integers. The neural network method can stop within 1 seconds by setting the mean square error tolerance threshold to 0.01. The fit I find is x = 16sin(theta)^3; y=13cos(theta) &#8211; 5cos(2theta)-2cos(3theta)-cos(4theta); and here is the result:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"468\" height=\"466\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-80.png\" alt=\"\" class=\"wp-image-7388\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-80.png 468w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-80-300x300.png 300w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-80-150x150.png 150w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-80-380x378.png 380w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-2-1024x768.jpg\" alt=\"\" class=\"wp-image-7389\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-2-1024x768.jpg 1024w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-2-300x225.jpg 300w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-2-768x576.jpg 768w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-2-1536x1152.jpg 1536w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-2-1140x855.jpg 1140w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-2-920x690.jpg 920w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-2-575x431.jpg 575w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-2-380x285.jpg 380w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-2.jpg 1702w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Last curve is rose curve: r = 35cos(theta); the center is the most tricky part since the nozzle will path the center point for multiple times. This will cause a hump forming in the center point. So what I do is adding a if statement logic, such that when x^2+y^2 is small(near center point), I will set z value aliitle bit smaller. In this way the hump will be gone.   <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"1024\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-5-768x1024.jpg\" alt=\"\" class=\"wp-image-7540\" style=\"aspect-ratio:0.75;width:554px;height:auto\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-5-768x1024.jpg 768w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-5-225x300.jpg 225w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-5-1152x1536.jpg 1152w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-5-1140x1520.jpg 1140w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-5-920x1227.jpg 920w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-5-575x767.jpg 575w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-5-380x507.jpg 380w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-5.jpg 1280w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-3-1024x768.jpg\" alt=\"\" class=\"wp-image-7394\" srcset=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-3-1024x768.jpg 1024w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-3-300x225.jpg 300w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-3-768x576.jpg 768w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-3-1536x1152.jpg 1536w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-3-1140x855.jpg 1140w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-3-920x690.jpg 920w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-3-575x431.jpg 575w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-3-380x285.jpg 380w, https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/image-3.jpg 1702w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The code I used can be find here:<br><a href=\"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/p3.gh\">https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-content\/uploads\/2023\/10\/p3.gh<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When I was in high school, polar curve is one of my favorite math subject. So I decided to use some concepts from the polar curve to finish this project. I will do the project based on three polar curves: spiral curve, rose curve, and heart shape curve. The major philosophy behind this is to define R and theta, then [&hellip;]<\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-7328","post","type-post","status-publish","format-standard","hentry","category-gcode_23"],"_links":{"self":[{"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/posts\/7328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/comments?post=7328"}],"version-history":[{"count":9,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/posts\/7328\/revisions"}],"predecessor-version":[{"id":7546,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/posts\/7328\/revisions\/7546"}],"wp:attachment":[{"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/media?parent=7328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/categories?post=7328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/handandmachine.org\/classes\/computational_fabrication\/wp-json\/wp\/v2\/tags?post=7328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}