mattrdowney / planetaria

A Unity framework for Euclidean 2-sphere games (e.g. 2D virtual reality games) [quasi-MIT license]
Other
10 stars 2 forks source link

Approximate equal size for triangles in SubdividedOctahedronSphere #52

Closed mattrdowney closed 6 years ago

mattrdowney commented 6 years ago

Harder than I originally thought.

My theory:

y = sine((.5 - manhattan_distance) pi); xz_magnitude = square_root(1 - y y); Vector2 xz = for manhattan_distance <= .5: arctangent2(v - .5, u - .5) otherwise: mirror across diamond and then run arctangent2()

mattrdowney commented 6 years ago

Partially solved as of bcf046d8d141edb9a231bed6ac5843815573f812

but using y=sine(.5 - manhattan_distance) actually makes the problem worse.

Using grid spacing seems to be y=(.5-manhattan_distance)*2 [implicitly]

mattrdowney commented 6 years ago

This should be possible with a simple integral of a sphere's surface (I think). The goal is to parameterize based on cumulative surface percent and get a height or angle phi that covers that percentage of the surface. (i.e. this might be Calculus 3 with spheres)

mattrdowney commented 6 years ago

Notably: there is a second goal here:

Defining the function so that generated spheres of level-of-detail 2-~16 UV map correctly.

This is a higher priority than equal area triangles, although I theorize they will both lead to the same thing.

mattrdowney commented 6 years ago

Partially solved as of 59fc0ce9e9286e9cb5ff2eec66e4375b14ee6f9a

This method uses equal sized phi segments for triangle strips, but does not use Calculus 3 integration.

mattrdowney commented 6 years ago

Triangles at the base seem to be 2x the area of triangles at the apex. I believe this is because the base has two 90 degree angles at the left and right side whereas the apex has a single 90 degree angle.

This means that in order to fix this I would need to do a trapezoid rule for the angle at the bottom/top of any given triangle strip to calculate the effective area.

mattrdowney commented 6 years ago

Virtually solved as of 20cb539cc71751ca9310c1568af6a9e118fdff5c

In theory some integration needs to be done (I'm fairly certain), but this is good enough and can be reopened if need be.

Currently, the triangles are made with equal angular sizes left and right and up and down.