{"id":74295,"date":"2022-10-12T09:24:45","date_gmt":"2022-10-12T13:24:45","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=74295"},"modified":"2022-10-12T09:24:45","modified_gmt":"2022-10-12T13:24:45","slug":"project-07-curves","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/12\/project-07-curves\/","title":{"rendered":"Project-07-Curves"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<html><body><p>A modified hypotrochoid on top of a modified epitrochoid! I reversed x and y in the second vertex function to create the double layered effect.<\/p>\n\n\n\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/10\/sketch-108.js\" data-width=\"480\" data-height=\"480\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"480\" height=\"480\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/ Zoe Lin (ID: youlin)\n\/\/ Section B\n\nvar nPoints = 80;\nvar angle;\nvar x, y, theta;\nvar r, g, b;\n\nfunction setup() {\n  createCanvas(480, 480);\n}\n\nfunction draw() {\n  r = map(mouseX, 0, width, 0, 20); \/\/draws bg color based on mouse pos\n  g = map(mouseY, 0, height, 0, 20);\n  b = map(mouseX, 0, height, 0, 20);\n  background(r, g, b);\n  noFill();\n  stroke(130);\n  translate(width\/2, height\/2);\n  moddedeEpitrochoid(); \/\/draws first geometry at center\n  rotate(HALF_PI); \/\/draws second at an angle\n  moddedeEpitrochoid();\n  hypotrochoid(); \n  rotate(PI \/ 3); \/\/repeat at third angle\n  moddedeEpitrochoid();\n  hypotrochoid();\n\nfunction moddedeEpitrochoid() {\n    var a = 85; \/\/angle\n    var h = constrain(mouseY \/ 10, 0, 100); \/\/limits geometry size\n    var mouse = mouseX \/ 70;\n    \n    beginShape();\n    for (var i = 0; i &lt; nPoints; i++) {\n        theta = map(i, 0, nPoints, 0, TWO_PI);\n        \/\/modified formula for epitrochoid\n        x = (a+a\/2) * sin(theta) - cos(mouse + theta * (a + a\/2) \/ a\/2) * h;\n        y = (a+a\/2) * cos(theta) - sin(mouse + theta * (a + a\/2) \/ a\/2) * h;\n        vertex(x, y);\n        vertex(y, x); \/\/layers vertexes, draws 2d geometry\n    }\n    endShape();\n }\n  strokeWeight(0.25);\n}\n\nfunction hypotrochoid() { \n    var h = constrain(mouseX \/ 100, 205, height); \/\/contrains geometry size\n    var a = map(mouseX, 0, width, 25, 15); \/\/maps mouse pos to desired angle\n    var b = map(mouseY, 0, height, 0, 15);\n    beginShape();\n      for (var i = 0; i &lt; nPoints-15; i ++) {\n        var theta2 = map(i, 0, width\/2, 0, 50);\n        \/\/hypotrochoid formula\n        x = (a - b) * cos(theta2) + h * sin((a - b) * theta2);\n        y = (a - b) * sin(theta2) - h * cos((a - b) * theta2);\n        vertex(x, y);\n      }\n    endShape();\n}<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>A modified hypotrochoid on top of a modified epitrochoid! I reversed x and y in the second vertex function to create the double layered effect. sketch \/\/ Zoe Lin (ID: youlin) \/\/ Section B var nPoints = 80; var angle; var x, y, theta; var r, g, b; function setup() { createCanvas(480, 480); } function &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/12\/project-07-curves\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project-07-Curves&#8221;<\/span><\/a><\/p>\n","protected":false},"author":740,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[108,56,1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74295"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/users\/740"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=74295"}],"version-history":[{"count":2,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74295\/revisions"}],"predecessor-version":[{"id":74298,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74295\/revisions\/74298"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=74295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=74295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=74295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}