# Hmm, sphere math that broke my head

Now this was straight forward for projecting a planet sphere at a specific distance away so that, no matter what maximum distance the view area is set at, the planet is still visible and scaled appropriately. This all worked and has been working.

The problem I have been running into is the equation to know how much of the planet to show at any one time. The equation for determining the visible surface area angle is the ArcCosine of the Radius of the Planet divided by the Distance the observer is to the center of the planet (which would be somewhere, perhaps high above the surface of the planet, which of course the surface would be the radius). Ok, that works fine. Take the circumference of the planet, divide that by 360, that gives you the distance per degree and you multiply that by what you got from the ArcCos (Yes, typical ACOS gives you radians, not degrees, but the concept still applies). This gives you the distance of the visible arc. Meaning, from the center point that the observer is directly over, how much distance FROM there can that observer see of the sphere. That all works. To get the size of the original triangle from the isohedron is 26 degrees or the ArcTangent of 1/2 (look it up). Multiply that by the same distance per degree as above and you get how big the original isohedron triangles are based on the radius of the planet. Ok, that all works.

Now I wanted to know what subdivision level I should be at to cover that area with a specific set of “rings” of triangles. Keep in mind that all the subdivisions are of that original isohedron triangle. And this kept screwing me up. Here is the solving equation:

Distance of Visible Arc/Number of Rings = Distance of Original Isohedron Triangle/ 2 to the power of X (X being the amount of subdivisions needed based on the number of desired rings).

A little algebra later and you get this:

2 to the power of x = (Distance of Original Isohedron Triangle/(Distance of Visible Arc/Number of Rings))

Now I thought the way to solve this was:

X=Square root of (Distance of Original Isohedron Triangle/(Distance of Visible Arc/Number of Rings))

It isn’t. That doesn’t work. That isn’t how you solve it. It’s not squareroot. It’s LOG to the base of 2. So the answer is finally:

X=log2(Distance of Original Isohedron Triangle/(Distance of Visible Arc/Number of Rings))

Older C didn’t have Log2, but did have Log10. So to emulate it, it is Log10(Distance of Original Isohedron Triangle/(Distance of Visible Arc/Number of Rings))/Log10(2). But it seems newer C has Log2.

Print article | This entry was posted by Arthur D Moyer on 05/16/18 at 05:49:00 pm . Follow any responses to this post through RSS 2.0. |