{"author_name":"Eliot","cat":"LD #23","comments":[{"author_name":"steamgirl","time":"April 21, 2012 11:38 pm","epoch":1335069480,"text":"Not really my strong suit, so not sure if it&#8217;s any help, but couldn&#8217;t you do a workaround for arcs that break that? Eg, if it&#8217;s more than # degrees, use a circle collision detection and deduct the remaining shape or something like that? Hopefully someone else will have a better answer&#8230; but it seems a shame to ditch it all-together.","spam":"N"},{"author_name":"","time":"April 22, 2012 12:03 am","epoch":1335070980,"text":"It will help to try and split the check up as much as possible, then the solution becomes more obvious.<br \/>\n If I&#8217;m reading this right you could do:","spam":"N"},{"author_name":"","time":"April 22, 2012 12:32 am","epoch":1335072720,"text":"I would do this: define an arc always with the first angle lower than the second, AND a boolean to define if it goes first-&gt;second or second-&gt;first (inverted). Just do the angle check and invert the result with the &#8220;invert&#8221; boolean. If you want to do that only when detecting the collision without changing the rest of the code, it would be somethin like this:<br \/>\n invert = first&gt;second<br \/>\n point_is_in_angle = min(first,second) &lt; point.t &lt; max(first,second)<br \/>\n point_is_in_angle ^= invert","spam":"N"},{"author_name":"","time":"April 22, 2012 4:12 am","epoch":1335085920,"text":"Thanks for the suggestions. I had two people respond on twitter telling me to just split the arc into two arcs along the axis, so I did that so I could move on to coding the rest of the game. I will definitely keep these suggestions in mind if I run into bugs, or have time to go back and clean things up, but the upshot is collision is more or less working now!","spam":"N"}],"epoch":1335068940,"likes":0,"metadata":{"p_key":"57150","p_author":"Eliot","p_authorkey":"8628","p_urlkey":"92899","p_title":"Looking for advice on arc\/point collision detection","p_cat":"LD #23","p_event":"LD23","p_time":"1335068940","p_likes":"0","p_comments":"4","p_status":"UPD5","us_key":"8628","us_name":"Eliot","us_username":"eliot","event_start":"1334880000","event_key":"10","event_name":"LD23"},"text":"<p>I&#8217;d appreciate some advice on whether my collison system can be salvaged or if I need to rewrite it.<br \/>\n My game is using polar coordinates and I am defining sections of arcs like so for the level geometry:<\/p>\n <p><a href=\"http:\/\/www.ludumdare.com\/compo\/2012\/04\/21\/off-to-a-good-start-3\/screen-shot-2012-04-21-at-1-04-19-am\/\" rel=\"attachment wp-att-121697\"><img class=\"alignnone size-large wp-image-121697\" src=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2012\/04\/Screen-Shot-2012-04-21-at-1.04.19-AM-550x412.png\" alt=\"\" width=\"550\" height=\"412\" srcset=\"http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2012\/04\/Screen-Shot-2012-04-21-at-1.04.19-AM-300x225.png 300w, http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2012\/04\/Screen-Shot-2012-04-21-at-1.04.19-AM-550x412.png 550w, http:\/\/ludumdare.com\/compo\/wp-content\/uploads\/2012\/04\/Screen-Shot-2012-04-21-at-1.04.19-AM.png 1023w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><br \/>\n Right now I wrote checks to see if a point at polar coordinate (r, theta) is inside the region between the greater and lesser arc that makes up a solid object, like so:<\/p>\n <pre>\n class Arc {\n \/\/Not a true arc, more of a segment of one or a \"Block Arc\", but it's much easier to type.\n float startAngle;\n float stopAngle;\n float maxRadius;\n float minRadius;\n \/\/...\n boolean collidesWith(PolarCoord point) {\n return !( startAngle &gt; point.t ||\n stopAngle &lt; point.t ||\n minRadius &gt; point.r ||\n maxRadius &lt; point.r );\n }\n \/\/...\n }\n <\/pre>\n <p>(<a href=\"https:\/\/github.com\/fadookie\/QEngine\/blob\/TinyWorld\/Arc.pde\">Full class is here<\/a>.)<\/p>\n <p>It appears my math doesn&#8217;t work out for arcs on certain intervals. Previously I had encountered issues with this code not working when a radian was less than 0 or greater than 2*pi, so I wrapped my radians between 0 and 2*pi which fixed it. But I need to define some arcs that start around, say, the radian equivalent of ~270 degrees and end at ~45 degrees, making the shape of the letter C and crossing the 0 degrees mark. This kind of arc breaks my collision check above.<\/p>\n <p>So I&#8217;m thinking, I can either fix my math for the check somehow, or abandon this method completely. Unfortunately I can&#8217;t find many resources on how to do this type of collision check properly. I couldn&#8217;t even find what these arc segment shapes are actually called.<\/p>\n <p>In addition, I&#8217;m seeing occasional tunneling issues and would like to switch to doing an arc segment + line segment test for continuous collision instead of just an arc\/point test.<\/p>\n <p>The alternative I thought of was to define my arcs based on a vector at the center and an angle, and use the dot product to the player to do my collison checks, similar to <a href=\"http:\/\/blog.wolfire.com\/2009\/07\/linear-algebra-for-game-developers-part-2\/\">the FOV check described here<\/a>.<\/p>\n <p>But it will take time to do that and I&#8217;d rather salvage this code if possible. If anyone has any advice, please let me know.<\/p>\n \n <p>Tags: <a href=\"http:\/\/ludumdare.com\/compo\/tag\/arc-collision\/\" rel=\"tag\">arc collision<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/polar-coordinates\/\" rel=\"tag\">polar coordinates<\/a>, <a href=\"http:\/\/ludumdare.com\/compo\/tag\/processing\/\" rel=\"tag\">processing<\/a><\/p>","time":"April 21st, 2012 11:29 pm","title":"Looking for advice on arc\/point collision detection"}