Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In a 3D sense you are first concerned with not with a circle but with the plane where the circle lies on. Then you can find the point of intersection between the ray (line) and the plane (disk).</p> <p>I like to use homogeneous coordinates for point, planes and lines and I hope you are familiar with vector dot <code>·</code> and cross products <code>×</code>. Here is the method:</p> <p>Plane (disk) is defined by a point vector <code>r=[rx,ry,rz]</code> and a normal direction vector <code>n=[nx,ny,nz]</code>. Together they form a plane <code>W=[W1,W2]=[n,-r·n]</code>.</p> <p>Line (ray) is defined by two point vectors <code>r_A=[rAx,rAy,rAz]</code> and <code>r_B=[rBx,rBy,rBz]</code>. Together they form the line <code>L=[L1,L2]=[r_B-r_A, r_A×r_B]</code></p> <p>The intersecting Point is defined by <code>P=[P1,P2]=[L1×W1-W2*L2, -L2·W1]</code>, or expanded out as</p> <pre><code>P=[ (r_B-r_A)×n-(r·n)*(r_A×r_B), -(r_A×r_B)·n ] </code></pre> <p>The coordinates for the point are found by <code>r_P = P1/P2</code> where <code>P1</code> has three elements and <code>P2</code> is scalar.</p> <p>Once you have the coordinates you check the distance with the center of the circle by <code>d=sqrt((r_p-r)·(r_p-r))</code> and checking <code>d&lt;=R</code> where <code>R</code> is the radius of the circle. Note the difference in notation between a scalar multiplication <code>*</code> and a dot product <code>·</code></p> <p>If you know for sure that the circles lie on the ground (<code>r=[0,0,0]</code>) and face up (<code>n=[0,0,1]</code>) then you can make a lot of simplifications to the above general case.</p> <p>[ref: <a href="http://www.flipcode.com/archives/Introduction_To_Plcker_Coordinates.shtml" rel="nofollow">Plucker Coordinates</a>]</p> <p><strong>Update:</strong></p> <p>When using the ground (with +Z up) as the plane (where circles lie), then use <code>r=[rx,ry,0]</code> and <code>n=[0,0,1]</code> and the above intersection point simplifies to</p> <pre><code>r_p = [ rBy-rAy, rAx-rBx, 0] / (rAy*rBx-rAx*rBy) </code></pre> <p>of which you can check the distance to the circle center.</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