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

Triangle UV coordinates with quasi-concentric rings (not triangles) based on distance from the center. #82

Open mattrdowney opened 6 years ago

mattrdowney commented 6 years ago

Not important/Hard to read.

The idea here is that a circle is angle 360 and a triangle is area 180, essentially the goal is to interpolate between the two.

In order to do this:

There are three vertex interpolators and three midpoint interpolators. A large chunk of the triangle has UVs calculated exactly the same as before.

Each triangle essentially has three/six quadrants, as distance from center increases the concentric "triangles" will look like they are going from circle -> rounded triangle -> actual triangle.

In order to do this, each vertex has 100% control over the line from its vertex to its opposite midpoint. The three midpoint distances are always the exact same as normal UV mapping (interpolated).

The vertex uses the two adjacent midpoints as start control points for quadratic bezier interpolation. The third control point is complicated, but it must be chosen to that the center->midpoint distance will create a curve that is of angle between 120 degrees (i.e. third of a "sorta circle") and 60 degrees (i.e. the angle of an equilateral triangle) accordingly.

In order to do this, consider the following: put the third control point between the two midpoint interpolators and you get a 180 degree angle (this should never happen) and put it at the vertex when using the actual midpoints and you would get a 60 degree angle as expected.

At 50% midpoint distance you would want the angles to be 90 degrees (halfway between 120 and 60).

In order to make the barycentric coordinates exactly the same, the midpoint interpolators must be shifted 50% of the way to the corner to find the beginning of the rounded triangle of the given angle.

mattrdowney commented 5 years ago

It's very possible this was supposed to be spherical Barycentric coordinates (I even referenced Barycentric coordinates in the last paragraph), although it only seems to mention 2D triangles.