{"id":74507,"date":"2022-10-15T19:46:06","date_gmt":"2022-10-15T23:46:06","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=74507"},"modified":"2022-10-15T19:46:06","modified_gmt":"2022-10-15T23:46:06","slug":"project-07-curves-4","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/15\/project-07-curves-4\/","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>For this project, if you move your mouse left and right it changes the size of the left and right petals. If you move your mouse up and down it changes the size of the rose curve and the top and bottom inner petals.<\/p>\n\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/10\/sketch-127.js\" data-width=\"400\" data-height=\"400\">sketch<\/a><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\">\/\/num of lines(rose) & size for bifoliate\nvar nPoints = 100;\n\n\nfunction setup() {\n    createCanvas(400, 400);\n    frameRate(50);\n    background(220);\n}\n\nfunction draw() {\n    background(0);\n\n    push();\n    \/\/moves origin to center of canvas\n    translate(width\/2, height\/2);\n    \/\/inner petals\n    draw4BifoliateCurve();\n    \/\/outer curves\n    drawRoseCurve();\n    pop();\n}\n\n\/\/creating one singular bifoliate curve\nfunction drawBifoliateCurve() {\n    var x;\n    var y; \n    var r;\n\n    \/\/conforming a (which controls the size of the bifoliate) to mouseX\n    var a = constrain(mouseX - 200, -100, 100); \n    \/\/opaque purple\n    fill(200, 162, 230, 100); \n    noStroke();\n    beginShape();\n    for (var i = 0; i &lt; nPoints; i++) {\n            \/\/remap i from 0 to 2PI to create theta\n            var t = map(i, 0, nPoints, 0, TWO_PI); \n            \/\/bifoliate equation\n            r = ((8*cos(t) * (sin(t)**2))\/(3 + cos(4*t))) * (a);\n            print(\"Value\" + a);\n\n            x = r * cos(t);\n            y = r * sin(t);\n            vertex(x,y); \n    }\n    endShape(CLOSE);\n\n}\n\n\/\/creating one bifoliate curve in y-direction\nfunction drawmouseYbifoliateCurve() {\n    var x;\n    var y; \n    var r;\n\n    var a = constrain(mouseY-200, -120, 120);\n\n    fill(200, 162, 200, 100);\n    noStroke();\n    beginShape();\n    for (var i = 0; i &lt; nPoints; i++) {\n            \/\/remap i from 0 to 2PI to create theta\n            var t = map(i, 0, nPoints, 0, TWO_PI);\n            \/\/bifoliate equation\n            r = ((8*cos(t) * (sin(t)**2))\/(3 + cos(4*t))) * (a);\n            \/\/print(\"Value\" + a);\n\n            \/\/change from polar to x and y\n            x = r * cos(t);\n            y = r * sin(t);\n            vertex(x,y); \n    }\n    endShape(CLOSE);\n \n}\n \n\/\/creating 4 Curves (Outer\/Inner Petals)   \nfunction draw4BifoliateCurve() {\n    push();\n    \/\/2 Petals (Top and Bottom)\n    rotate(PI\/5);\n    drawmouseYbifoliateCurve();\n    rotate(PI)\n    drawmouseYbifoliateCurve();\n    pop();\n    \/\/2 Petals (Left and Right)\n    drawBifoliateCurve();\n    push();\n    rotate(PI);\n    drawBifoliateCurve();\n    pop();\n}\n\n\/\/draws rose curve\nfunction drawRoseCurve() {\n    var x;\n    var y; \n    var r;\n    var a = 1500;\n    \/\/mouse Y controls how many lines\n    var n = constrain(mouseY\/20, 0, 400\/20);\n\n    stroke(255, 255, 255, 150);\n    strokeWeight(0.5);\n    noFill();\n    beginShape();\n    for (var i = 0; i &lt; nPoints; i++) {\n            \/\/remap i from 0 to 2PI to create theta\n            var t = map(i, 0, nPoints, 0, TWO_PI);\n\n            \/\/rose equation\n            r = a*sin(n*t);\n\n            \/\/change from polar to x and y\n            x = r * cos(t);\n            y = r * sin(t);\n            vertex(x,y); \n    }\n    endShape();\n\n}\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>For this project, if you move your mouse left and right it changes the size of the left and right petals. If you move your mouse up and down it changes the size of the rose curve and the top and bottom inner petals. sketch \/\/num of lines(rose) &#038; size for bifoliate var nPoints = &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/10\/15\/project-07-curves-4\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 07: Curves&#8221;<\/span><\/a><\/p>\n","protected":false},"author":753,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[108,56],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74507"}],"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\/753"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=74507"}],"version-history":[{"count":2,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74507\/revisions"}],"predecessor-version":[{"id":74510,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/74507\/revisions\/74510"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=74507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=74507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=74507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}