{"id":2657,"date":"2016-06-25T19:13:40","date_gmt":"2016-06-25T19:13:40","guid":{"rendered":"http:\/\/louisc.co.uk\/?p=2657"},"modified":"2016-11-05T11:17:47","modified_gmt":"2016-11-05T11:17:47","slug":"placing-points-along-an-arc-using-geomerative-polygonizer-and-processing","status":"publish","type":"post","link":"https:\/\/louisc.co.uk\/?p=2657","title":{"rendered":"Placing points along an Arc using Geomerative Polygonizer and Processing"},"content":{"rendered":"<p>This is a follow on from <strong><span style=\"text-decoration: underline;\"><a href=\"http:\/\/louisc.co.uk\/?p=2623\">this post on drawing arcs with Geomerative<\/a><\/span><\/strong>, a great library for processing\u00a0(<span style=\"text-decoration: underline;\"><strong><a href=\"http:\/\/www.ricardmarxer.com\/geomerative\/\" target=\"_blank\">Website<\/a><\/strong><\/span>) by<strong> <a href=\"http:\/\/www.ricardmarxer.com\/\" target=\"_blank\">Ricard Marxer<\/a>.<\/strong>\u00a0 I have struggled to find many similar sketches online other than those included in the examples, so i figured I would share my progress. This post whilst keeping a log for my own future use, I hope may serve as a reference for others\u00a0out there with the same aims as me.<\/p>\n<p>Here we will begin to investigate how we can also place text along these arcs. In order to do so, we will need to establish the coordinates of regularly spaced points along the curve surface. We will also continue on with the same code for familiarity.<\/p>\n<p>First attempt was to figure out exactly what the getPoints() \u00a0function within the RShape class retrieves. Once we call this function and place the points into a point array, we can draw each one by simply adding a quick for loop (This method is used in the geomerative tutorial &#8220;HelloWorld_GetPoints&#8221; with text).<\/p>\n<div class=\"fusion-fullwidth fullwidth-box hundred-percent-fullwidth non-hundred-percent-height-scrolling\"  style='background-color: rgba(255,255,255,0);background-position: center center;background-repeat: no-repeat;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;'><div class=\"fusion-builder-row fusion-row \"><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t<div id=\"attachment_2658\" style=\"width: 810px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2658\" class=\"size-full wp-image-2658\" src=\"http:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000029.jpg\" alt=\"Adding blue points at each &quot;point&quot; returned by getPoints() function.\" width=\"800\" height=\"600\" srcset=\"https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000029-200x150.jpg 200w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000029-300x225.jpg 300w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000029-400x300.jpg 400w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000029-600x450.jpg 600w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000029-768x576.jpg 768w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000029.jpg 800w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><p id=\"caption-attachment-2658\" class=\"wp-caption-text\">Adding blue points at each &#8220;point&#8221; returned by getPoints() function.<\/p><\/div>\n<p>The code to produce this is:<\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nimport geomerative.*;\r\n\r\nRShape wave;\r\n\r\nfloat movement=0;\r\nfloat plusminus = 5.0;\r\nfloat scale = 3;\r\n\r\n\/\/Somwhere to store our curve points\r\nRPoint[] points;\r\n\r\nvoid setup()\r\n{\r\n \/\/ From the examples we must always initialise the library using this command\r\n RG.init(this);\r\n \r\n \/\/Usual Processing Jazz\r\n size(800 ,600);\r\n background(255);\r\n frameRate(25);\r\n}\r\n\r\nvoid draw(){\r\n \/\/Blank Background each frame\r\n background(255);\r\n \r\n \/\/Iterate our movement variable for animation\r\n movement += plusminus;\r\n \r\n \/\/Create a new RShape each frame\r\n RShape wave = new RShape();\r\n \r\n \/\/At the moment the wave object is empty, so lets add a curve:\r\n wave.addMoveTo(0*scale, 100*scale);\r\n wave.addBezierTo(0*scale, 100*scale, 50*scale, (25+movement)*scale, 100*scale, 100*scale);\r\n wave.addBezierTo(100*scale, 100*scale, 150*scale, (175-movement)*scale, 200*scale, 100*scale); \r\n \r\n \/\/Lets start to draw away from the edges\r\n translate(30*scale,0*scale);\r\n \r\n \/\/Draw our wave\r\n noFill();\r\n stroke(0);\r\n strokeWeight(1*scale);\r\n wave.draw();\r\n \r\n \/\/Add some points along the curve\r\n points = wave.getPoints(); \r\n \r\n stroke(0, 90, 255); \/\/Blue\r\n strokeWeight(5);\r\n for(int i=0; i&amp;amp;amp;lt;points.length; i++){ point(points[i].x, points[i].y); } \/\/Draw our bezier handle lines strokeWeight(0.5*scale); line(0*scale,100*scale,50*scale,(25+movement)*scale); line(150*scale,(175-movement)*scale,200*scale,100*scale); \/\/Finally draw our defined control points strokeWeight(5*scale); stroke(0, 255, 0); \/\/Green point(0*scale,100*scale); stroke(0, 0, 255); \/\/Blue point(50*scale,(25+movement)*scale); point(150*scale,(175-movement)*scale); stroke(255, 0, 0); \/\/Red point(200*scale,100*scale); \/\/If we are at the top of our movement, reverse the directing by \/\/changing the plusminus variable if(movement &amp;amp;amp;gt; 150)\r\n {\r\n plusminus = -5;\r\n }else if( movement &amp;amp;amp;lt;= 0)\r\n {\r\n plusminus = 5;\r\n }\r\n\r\n}\r\n<\/pre>\n<p>As the density of points returned by getPoints() is so high, it seems that the whole line is just a badly smoothed blue line. So we can prove to ourselves\u00a0\u00a0this is not the case by quickly plotting half the points:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2661 alignnone\" src=\"http:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000064.jpg\" alt=\"louisc_co_uk_Geromerative2-000064\" width=\"800\" height=\"600\" srcset=\"https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000064-200x150.jpg 200w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000064-300x225.jpg 300w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000064-400x300.jpg 400w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000064-600x450.jpg 600w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000064-768x576.jpg 768w, https:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative2-000064.jpg 800w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>Done by adjusting the bounds of the for loop:<\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nfor(int i=0; i&amp;amp;lt;points.length\/2; i++){\r\n point(points[i].x, points[i].y);\r\n }\r\n<\/pre>\n<p>That is far too many points for our requirements, now we could look into just drawing every n-th point but the geomerative example alludes to a better way, manipulating the &#8220;Polygonizer&#8221;.<\/p>\n<h2>Better understanding the Geomerative &#8220;Polygonizer&#8221;<\/h2>\n<p>Now these values seem to be something we set in the library directly, rather than to the shape objects themselves, implying that this will cause a global change. Lets have a play and see what some of these options do.<\/p>\n<p>First lets take the &#8220;UNIFORMLENGTH&#8221; setting used in the tutorial, manually defining a length of 30 and 100.<\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\r\nRG.setPolygonizer(RG.UNIFORMLENGTH);\r\nRG.setPolygonizerLength(30);\r\n\r\n<\/pre>\n<p>The two resultant outputs are:<\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t<div id=\"attachment_2666\" style=\"width: 810px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2666\" class=\"size-full wp-image-2666\" src=\"http:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative_POLYG_UNI_30-000001.gif\" alt=\"Here is an animation of the UNIFORMLENGTH Polygonizer with different lengths of 30 and 100.\" width=\"800\" height=\"316\" \/><p id=\"caption-attachment-2666\" class=\"wp-caption-text\">Here is an animation of the UNIFORMLENGTH Polygonizer with different lengths of 30 and 100.<\/p><\/div>\n<p>This simple animation works well to show how the UNIFORMLENGTH mode of the polygonizer responds. As the length of the curve increases, further points are added to maintain the specified\u00a0length between them.<\/p>\n<p>Next a quick look at the alternative modes of:<\/p>\n<p>&nbsp;<\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nRG.setPolygonizer(RG.UNIFORMSTEP);\r\nRG.setPolygonizerStep(10);\r\n<\/pre>\n<p>and<\/p>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nRG.setPolygonizer(RG.ADAPTATIVE);\r\n<\/pre>\n<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><div  class=\"fusion-layout-column fusion_builder_column fusion_builder_column_1_1  fusion-one-full fusion-column-first fusion-column-last fusion-column-no-min-height 1_1\"  style='margin-top:0px;margin-bottom:0px;'>\n\t\t\t\t\t<div class=\"fusion-column-wrapper\" style=\"background-position:left top;background-repeat:no-repeat;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;background-size:cover;\"  data-bg-url=\"\">\n\t\t\t\t\t\t<div id=\"attachment_2669\" style=\"width: 810px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-2669\" class=\"size-full wp-image-2669\" src=\"http:\/\/louisc.co.uk\/wp-content\/uploads\/2016\/06\/louisc_co_uk_Geromerative_POLYG_ADAPvsUNIFSTEP.gif\" alt=\"This animation compared the ADAPTIVE and UNIFORMSTEP modes of the polygonizer\" width=\"800\" height=\"316\" \/><p id=\"caption-attachment-2669\" class=\"wp-caption-text\">This animation compared the ADAPTIVE and UNIFORMSTEP modes of the polygonizer<\/p><\/div>\n<p>The next post will cover using these points to place text along the curve.<div class=\"fusion-clearfix\"><\/div>\n\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This is a follow on from this post on drawing arcs with Geomerative, a great library for processing\u00a0(Website) by Ricard Marxer.\u00a0 I have struggled to find many similar sketches online other than those included in the examples, so i figured I would share my progress. This post whilst keeping a log for my own future use, I hope may serve as a reference for others\u00a0out there with the same aims as me. Here we will begin to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2666,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[103,108,28,1],"tags":[112,113,105,109,110,107],"class_list":["post-2657","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kinetic-storyteller","category-programming","category-projects","category-uncategorized","tag-design","tag-geomerative","tag-graphics","tag-processing","tag-programming","tag-tine-bech"],"_links":{"self":[{"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2657"}],"version-history":[{"count":13,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2657\/revisions"}],"predecessor-version":[{"id":2715,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2657\/revisions\/2715"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=\/wp\/v2\/media\/2666"}],"wp:attachment":[{"href":"https:\/\/louisc.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/louisc.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}