{"id":176,"date":"2012-11-01T15:29:57","date_gmt":"2012-11-01T15:29:57","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/?p=176"},"modified":"2012-11-01T15:29:57","modified_gmt":"2012-11-01T15:29:57","slug":"test","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/2012\/11\/01\/test\/","title":{"rendered":"test"},"content":{"rendered":"<p><script type=\"application\/processing\">\r\n\/**\r\n * Reach 1. \r\n * Based on code from Keith Peters (www.bit-101.com)\r\n * \r\n * The arm follows the position of the mouse by\r\n * calculating the angles with atan2(). \r\n *\/\r\n\r\n \r\nfloat x = 250;\r\nfloat y = 250;\r\nfloat x2 = 250;\r\nfloat y2 = 250;\r\nfloat segLength = 110;\r\n\r\nvoid setup() {\r\n  size(500, 500);\r\n  smooth(); \r\n  strokeWeight(20.0);\r\n  stroke(0, 100);\r\n}\r\n\r\nvoid draw() {\r\n  background(226);\r\n  \r\n  float dx = mouseX - x;\r\n  float dy = mouseY - y;\r\n  float angle1 = atan2(dy, dx);  \r\n  \r\n  float tx = mouseX - cos(angle1) * segLength;\r\n  float ty = mouseY - sin(angle1) * segLength;\r\n  dx = tx - x2;\r\n  dy = ty - y2;\r\n  float angle2 = atan2(dy, dx);  \r\n  x = x2 + cos(angle2) * segLength;\r\n  y = y2 + sin(angle2) * segLength;\r\n  \r\n  segment(x, y, angle1); \r\n  segment(x2, y2, angle2); \r\n}\r\n\r\nvoid segment(float x, float y, float a) {\r\n  pushMatrix();\r\n  translate(x, y);\r\n  rotate(a);\r\n  line(0, 0, segLength, 0);\r\n  popMatrix();\r\n}\r\n\r\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/176"}],"collection":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/comments?post=176"}],"version-history":[{"count":1,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/176\/revisions"}],"predecessor-version":[{"id":190,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/posts\/176\/revisions\/190"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/media?parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/categories?post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/IMGD3x00_B12\/wp-json\/wp\/v2\/tags?post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}