Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This solution is specific to your application where the vectors emanate from the origin and the icosahedron is centered at the origin.</p> <p>Define 20 triangles using the 12 verticies of the icosahedron. Order the 3 so that they are in counterclockwise order when viewed from outside the icosahedron. So for each triangle you'll have a list of 3 verticies. For each triangle construct a 3x3 matrix where the columns are the verticies of the triangle:</p> <pre> [ x1 x2 x3 ] T = [ y1 y2 y3 ] [ z1 z2 z3 ] </pre> <p>You'll need the inverse of this matrix (search SO or google for a fast 3x3 inverse in the language of your choice). Now for each vector, you want to multiply it by all 20 matricies. So for each triangle compute:</p> <p>B = V*T(inverse)</p> <p>If all 3 elements of B are positive (negative?) this is the intersected triangle.</p> <p>Next, normalize B - divide it by its length so it has unit length. This will make B the Barycentric coordinates of the intersection point on that triangle. You can also compute the actual intersection point I by multiplying the Barycentric coordinates by the original point matrix:</p> <p>I = B*T</p> <p>This also works for finding the 2D coordinates of the intersection point on the unfolded triangle. So use the 2x3 matrix of 2D coordinates instead of T.</p> <p>One last optimization. If you sum the 3 verticies of each triangle this will give you a normal vector for that triangle. If you compute the dot product of your vector with each of the normals, the triangle with the largest dot product will be the one intersected. This fact is specific to regular polyhedrons centered at the origin with the rays in question emanating from the origin. This is faster than doing the whole matrix multiply to determine which one is hit. You'll still need to do 1 matrix multiply to find the Barycentric coordinates.</p> <p>You can also search for ray-triangle intersection and read about Barycentric coordinates, but those solutions will be more generalized than this specific problem requires.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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