Skip to main content
1 of 4

Test if a point is in an Icosahedron

Take as input 3 floating point numbers, which represent the x, y, z coordinates of a point. Return a truthy or falsey value indicating whether the point is inside the regular icosahedron centred at the origin, with top and bottom vertices at (0, 0, 1) and (0, 0, -1), and with one of the upper ring of middle vertices in the +X+Z quarterplane. Input/output formats can be anything reasonable. To allow for rounding error, Your code does not have to give correct answers for points within 10^-6 units of the boundary

Example inputs / outputs:

0, 0, 0 => true
1, 1, 1 => false
0.7, 0.5, -0.4 => true
-0.152053, -0.46797, 0.644105 => false
-0.14609, -0.449618, 0.618846 => true

To be absolutely clear on the orientation of the icosahedron, the coordinates of the vertices are approximately

{{0., 0., -1.}, {0., 0., 1.}, {-0.894427190999916, 
 0., -0.447213595499958}, {0.894427190999916, 0., 
 0.447213595499958}, {0.723606797749979, -0.5257311121191336, 
-0.447213595499958}, {0.723606797749979, 
 0.5257311121191336, -0.447213595499958}, {-0.723606797749979, 
-0.5257311121191336, 0.447213595499958}, {-0.723606797749979, 
 0.5257311121191336, 
 0.447213595499958}, {-0.27639320225002106, -0.85065080835204, 
-0.447213595499958}, {-0.27639320225002106, 
 0.85065080835204, -0.447213595499958}, {0.27639320225002106, 
-0.85065080835204, 0.447213595499958}, {0.27639320225002106, 
 0.85065080835204, 0.447213595499958}}