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

True spherical coordinates (rho, phi, theta) #138

Open mattrdowney opened 5 years ago

mattrdowney commented 5 years ago

Not just unit-sphere/normalized spherical coordinates.

All you need is two extra spheres for representing the z-axis for collisions.

The first one is easy (just pick the max z distance and use that as a radius) Excluding the points up to the min z distance is a little harder, but there are two possibilities I know (binary negation (I've thought about this but want to avoid if possible) and negative radius (I have to think about this more)).

Of course, correctness is the primary concern. You don't want any false positives or false negatives on collisions.

Additionally, points according to this principle need two points for comparison -- the normalized one (same as before) and a point for the z-distance comparison.

Upon thinking about this further, it would probably be best to have a valid float range instead for depth, especially since it can be used in the broadphase collision detection as a sorting metric to avoid unnecessary comparisons (as an AABB of sorts).

I do like the idea of parallelizing sphere against sphere comparisons, but I will have to research further to continue down that route.

mattrdowney commented 5 years ago

Another interesting point about z-distance:

If you use the sphere method it's hard to adjust the elevation of an object (e.g. if a character jumps or an elevator moves up a floor).

mattrdowney commented 5 years ago

A possible advantage to using floating point ranges to represent whether two objects can collide:

You can implicitly represent different levels and their own potential collisions.

E.g. one world may be in the range [1,2) and the other might be in the range [2,3).

At the same time, this information is probably more succinctly summarized as a PlanetariaLayer (int/enum) that has its own independent collisions. Moreover, if you use floats as the primary sorting metric, space partitioning becomes harder in my opinion, since you can't fallback on bounding volume hierarchies easily.

mattrdowney commented 5 years ago

I should also mention: adding collisions in this third dimension adds a lot of complexity (at least if you are retrofitting the engine).

I don't think having spherical coordinates would be all that useful overall, so this is more of a thought experiment than an intended feature.