0

If I have an approximation of a sphere, how do I map the vertices of the sphere to form a (rectangular) tetrahedron?

My current approach maps all vertices of the sphere to just one of the four vertices of a tetrahedron. However I want them to be evenly spaced, if that is possible.

I would be thankful for any approach or solution.

  • 1
    While an interesting question, you might have more luck with this question on [computergraphics.se] or even [math.se], which are less practically programming oriented and could help you more with broader algorithmic guidance. – Christian Rau Nov 07 '16 at 21:28
  • Thanks, I'll post my question there. – noobprogrammer Nov 07 '16 at 22:43
  • But make sure not to just cross-post your question to multiple sites, this is highly discouraged. Pick a single site and post it there. Or flag this one for migration. – Christian Rau Nov 07 '16 at 22:46
  • 1
    What is a rectangular tetrahedron? – Beta Nov 08 '16 at 03:12
  • did you mean something similar to this: [Procedural generation of stars with skybox](http://stackoverflow.com/a/38068390/2521214) ? what do you want to be evenly spaced sphere vertexes or tetrahedron (what shape that exactly is?)? – Spektre Nov 08 '16 at 09:18
  • @Beta I meant "regular" – noobprogrammer Nov 08 '16 at 18:21
  • @Christian Rau Unfortunately I already posted my question in math, I'll keep it in mind for next time. Sorry – noobprogrammer Nov 08 '16 at 18:28
  • @Spektre Yes, but instead with a cube, I want to project the coordinates onto a tetrahedron. [link](https://upload.wikimedia.org/wikipedia/commons/8/83/Tetrahedron.jpg). – noobprogrammer Nov 08 '16 at 18:38

1 Answers1

1

One way to think about it is to imagine a sphere inside a tetrahedron and imagine projecting a ray from the center of the sphere until it cuts the tetrahedron.

Getting the equations of the points in a tetrahedron is a bit tricky. Perhaps easiest imagining it embedded in a cube of side length 2, with vertices at (1,1,1), (-1,-1,1), (1,-1,-1), (-1,1,-1). The equations of the faces are x + y + z = 1, x - y - z = 1, - x + y - z = 1, - x - y + z = 1.

So for a given point on the unit sphere x = sin(theta) cos(phi), y = sin(theta) sin(phi), z = cos(theta). We just need to find the point (r x, r y, r z) which satisfies one of the four equations. Say for example we might have r x + r y + r z = 1. If we know x, y, z its easy enough to solve for r: r = 1/(x+y+z).

Its a bit tricky working out which face to project to, an easy way around this is just calculate r1 = 1/(x+y+z), r2=1/(x-y-z), r3=1/(-x+y-z), r4=1/(-x-y+z). Discard any negative values and take the smallest of the remainder.

Here is a projection of a sphere using this technique.

enter image description here

Salix alba
  • 7,536
  • 2
  • 32
  • 38
  • Is it possible for r1, r2, r3 or r4 to be equal? How would I deal with that? – noobprogrammer Nov 08 '16 at 18:33
  • There is not a problem here. All we want to do is find the closest point on the ray to the origin. If the ray passes through an edge then it will cross two planes at the same distance so r1 = r2 say. If it passes through a vertex then three of the radii will be equal, all giving the same point. – Salix alba Nov 08 '16 at 18:56