{"id":1034,"date":"2015-11-04T04:56:19","date_gmt":"2015-11-04T04:56:19","guid":{"rendered":"http:\/\/blogs.discovery.wisc.edu\/projects\/?p=1034"},"modified":"2015-11-04T05:32:31","modified_gmt":"2015-11-04T05:32:31","slug":"week-9-oscillation","status":"publish","type":"post","link":"https:\/\/blogs.discovery.wisc.edu\/projects\/2015\/11\/04\/week-9-oscillation\/","title":{"rendered":"Week 9 &#8211; Oscillation"},"content":{"rendered":"<p>This week I covered Chapter 3 of &#8220;The Nature of Code&#8221;. The chapters keep getting\u00a0 more and more in depth and the exercises more complicated. But I was able to finish two of the exercises and create a neat little artistic particle system using a trig function to define a boundary. You can see it <a href=\"http:\/\/www.openprocessing.org\/sketch\/228018\">here<\/a>.<\/p>\n<p>In the past we have covered motion and we borrow the same principles of motion simulation to model oscillation in the Processing environment. Before we had the following two key statements to make agents move:<\/p>\n<p>location.add(velocity);<\/p>\n<p>Now for oscillation we use:<\/p>\n<p>angle.add(avelocity);<\/p>\n<p>We know that both sin and cos oscillate between (-1,1). In a past week, I implemented the notion of using trig functions with the frameCount to define the locations of drawn elements. This is essentially what we will do also with an oscillator, whose x and y coordinates will be given by Amplitude * sin( some increasing angle) and Amplitude * cos (some increasing angle). The first exercise asked me to find a way to make a pattern out of an array of oscillators. I used trig functions to make initialize the velocities in a rhythmic pattern:<\/p>\n<div id=\"attachment_1037\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9.jpg\"><img aria-describedby=\"caption-attachment-1037\" loading=\"lazy\" class=\"size-medium wp-image-1037\" src=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-300x171.jpg\" alt=\"Oscillator class\" width=\"300\" height=\"171\" srcset=\"https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-300x171.jpg 300w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-1024x582.jpg 1024w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-500x284.jpg 500w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9.jpg 1714w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1037\" class=\"wp-caption-text\">Oscillator class\\<\/p><\/div>\n<div id=\"attachment_1038\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-2.jpg\"><img aria-describedby=\"caption-attachment-1038\" loading=\"lazy\" class=\"size-medium wp-image-1038\" src=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-2-300x171.jpg\" alt=\"Initialization of Oscillators' velocities with trig functions\" width=\"300\" height=\"171\" srcset=\"https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-2-300x171.jpg 300w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-2-1024x582.jpg 1024w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-2-500x284.jpg 500w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-2.jpg 1632w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1038\" class=\"wp-caption-text\">Initialization of Oscillators&#8217; velocities with trig functions<\/p><\/div>\n<p>We also looked at waves. The exercise I did required me to encapsulate a wave into a class and create a pattern:<\/p>\n<div id=\"attachment_1039\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-3.jpg\"><img aria-describedby=\"caption-attachment-1039\" loading=\"lazy\" class=\"size-medium wp-image-1039\" src=\"http:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-3-300x176.jpg\" alt=\"Wave Class and Pattern\" width=\"300\" height=\"176\" srcset=\"https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-3-300x176.jpg 300w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-3-1024x601.jpg 1024w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-3-500x293.jpg 500w, https:\/\/blogs.discovery.wisc.edu\/projects\/files\/2015\/11\/week-9-3.jpg 1966w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1039\" class=\"wp-caption-text\">Wave Class and Pattern<\/p><\/div>\n<p>This week I will be looking at Chapter 4 and hopefully conceive a colliding particle system.<\/p>\n<p>See you soon.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week I covered Chapter 3 of &#8220;The Nature of Code&#8221;. The chapters keep getting\u00a0 more and more in depth and the exercises more complicated. But I was able to finish two of the exercises and create a neat little &hellip; <a href=\"https:\/\/blogs.discovery.wisc.edu\/projects\/2015\/11\/04\/week-9-oscillation\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":105,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/posts\/1034"}],"collection":[{"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/users\/105"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/comments?post=1034"}],"version-history":[{"count":3,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/posts\/1034\/revisions"}],"predecessor-version":[{"id":1040,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/posts\/1034\/revisions\/1040"}],"wp:attachment":[{"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/media?parent=1034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/categories?post=1034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.discovery.wisc.edu\/projects\/wp-json\/wp\/v2\/tags?post=1034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}