Note that there are some explanatory texts on larger screens.

plurals
  1. PODetecting wether a point is inside a SVG Path
    text
    copied!<p>I'm trying to detecting wether a given point is inside a closed SVG path in Objective-C. I'm having trouble figuring out how to do the math.</p> <p>I have a path's coordinates and I'd like to determine wether a random point is inside or outside the path.</p> <p>Here's an example of a path's coordinates:</p> <pre><code>"M673 460 c2 0 4 -1 5 -2 1 -1 2 -2 2 -4 0 -2 0 -3 0 -3 0 0 -3 1 -5 1 -3 1 -5 2 -5 3 0 1 0 3 0 4 1 0 2 1 3 1z:" </code></pre> <p>I'm aware of the CoreGraphics's <code>containsPoint:</code> method, but I'd like to avoid using this method.</p> <p>How can I do this by writing my own method?</p> <p><strong>EDIT:</strong></p> <p>I'm trying to avoid <code>containsPoint:</code> because the function seems to crash on some coordinates / paths when using it. It looks quite random when it crashes and when it doesn't.</p> <p>Here are some examples of paths where <code>containsPoint:</code> makes the app crash:</p> <pre><code>"M661 446 c1 -1 3 -1 4 -1 1 -1 2 -2 2 -4 0 -2 0 -2 -2 -2 0 1 -2 1 -3 1 -2 0 -3 1 -3 2 0 1 0 2 0 3 0 0 1 1 2 1z" "M535 460 c0 0 1 -1 1 -2 1 -2 0 -3 -1 -3 0 0 -1 0 -2 1 0 1 0 2 0 3 1 0 1 1 2 1z" </code></pre> <p>Xcode breaks with and <code>EXC_BAD_ACCESS</code> in the assembly by the following two functions: <code>get_y_inflections</code> and <code>get_cubic_coefficients</code>.</p> <p><strong>EDIT 2:</strong></p> <p>I posted a <a href="https://stackoverflow.com/questions/12489988/containspoint-for-uibezierpath-crashes">new question</a> about the <code>containsPoint:</code> problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload