{"id":74537,"date":"2022-10-15T20:40:30","date_gmt":"2022-10-16T00:40:30","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=74537"},"modified":"2022-10-15T20:40:53","modified_gmt":"2022-10-16T00:40:53","slug":"74537","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/15\/74537\/","title":{"rendered":"Project 07"},"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>this is my project.<\/p>\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/10\/sketch-133.js\" data-width=\"400\" data-height=\"400\">sketch<\/a>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"400\" height=\"400\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">var nPoints = 400;\n\nfunction setup() {\n    createCanvas(400, 400); \n}\n\n\nfunction draw() {\n    background(0);\n    \n    \/\/ draw the curve\n    push();\n    translate(width\/2, height\/2);\n    drawEpitrochoidCurve();\n    pop();\n\n    push();\n    translate(width\/2, height\/2-20)\n    drawCardioidCurve();\n    pop();\n}\n\n\/\/--------------------------------------------------\nfunction drawEpitrochoidCurve() {\n    \/\/ Epicycloid:\n    \/\/ http:\/\/mathworld.wolfram.com\/Epicycloid.html\n    noFill();\n    strokeWeight(1);\n\n    \/\/change color \n    if (mouseX&lt; width\/2) {\n        stroke(0, 50, 233);\n    } else {\n        stroke(81, 211, 255);\n    }\n\n    var x = constrain(mouseX, 0, width);\n    var y = constrain(mouseY, 0, height);\n    var a = map(x, 0, width, 50, 150);\n    var b = map(y, 0, height, 1, 6);\n    var h = constrain(mouseY, 50, 90);\n    \n    \/\/draw Epicycloid\n    beginShape();\n    for (var i = 0; i &lt; nPoints; i++) {\n        var t = map(i, 0, nPoints, 0, TWO_PI);\n        \n        x = (a + b) * cos(t) - h * cos(t * (a + b) \/ b);\n        y = (a + b) * sin(t) - h * sin(t * (a + b) \/ b);\n        vertex(x, y);\n    }\n    endShape(CLOSE);\n    \n}\n\n\n\/\/--------------------------------------------------\nfunction drawCardioidCurve() {\n    \/\/Cardioid\n    \/\/ https:\/\/mathworld.wolfram.com\/Cardioid.html\n    push();\n    translate(x, y);\n    rotate(radians(-90))\n    var x = constrain(mouseX, 0, width);\n    var y = constrain(mouseY, 0, height);\n    var a = map(x, 0, width, 20, 80);\n    var b = a\/2;\n   \n    \/\/change color\n    if (mouseY &gt; height\/2) {\n        fill(233, 50, 50, 200);\n    } else {\n        fill(169, 22, 22, 200);\n    }\n\n    \/\/draw cardioid\n    strokeWeight(1)\n    stroke(244, 82, 255);\n    beginShape();\n    for (var i = 0; i &lt; nPoints; i++) {\n        var t = map(i, 0, nPoints, 0, TWO_PI);\n\n        x = a*cos(t)*(1-cos(t));\n        y = a*sin(t)*(1-cos(t));\n        vertex(x, y);\n    }\n    endShape(CLOSE);\n    pop();\n    \n}\n\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>this is my project. sketch var nPoints = 400; function setup() { createCanvas(400, 400); } function draw() { background(0); \/\/ draw the curve push(); translate(width\/2, height\/2); drawEpitrochoidCurve(); pop(); push(); translate(width\/2, height\/2-20) drawCardioidCurve(); pop(); } \/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; function drawEpitrochoidCurve() { \/\/ Epicycloid: \/\/ http:\/\/mathworld.wolfram.com\/Epicycloid.html noFill(); strokeWeight(1); \/\/change color if (mouseX&lt; width\/2) { stroke(0, 50, 233); } else &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/15\/74537\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 07&#8221;<\/span><\/a><\/p>\n","protected":false},"author":777,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[108,55],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74537"}],"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\/777"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=74537"}],"version-history":[{"count":6,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74537\/revisions"}],"predecessor-version":[{"id":74548,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74537\/revisions\/74548"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=74537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=74537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=74537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}