GeometryCollective / boundary-first-flattening

MIT License
768 stars 96 forks source link

Sphere flatenning #63

Closed petrasvestartas closed 1 year ago

petrasvestartas commented 4 years ago

Hi,

I am using command line interface.

For 2d flatenning I use texture coordinates to buid a mesh from out.obj.

For a unit sphere mesh how can I build mesh from texture coordinates since these are x and y values and there is no z coord?

I tried simple from polar to cartesian conversion but it wont work

                    p.X = 1 * Math.Sin(v.X) * Math.Cos(v.Y);
                    p.Y = 1 * Math.Sin(v.X) * Math.Sin(v.Y);
                    p.Z = 1 * Math.Cos(v.X);

Conversion

rohan-sawhney commented 4 years ago

Hi @petrasvestartas, the spherical uv coordinates are mapped to the plane using the procedure described here: https://en.wikipedia.org/wiki/UV_mapping#Finding_UV_on_a_sphere. You could invert that, or probably the simplest thing to do would be to just to write out the 3d spherical coordinates by commenting out the conversion to the plane here: https://github.com/GeometryCollective/boundary-first-flattening/blob/e9bce6e0a7da5c12f5537e87a23ed6e94fdb2f47/mesh/src/MeshIO.cpp#L589

petrasvestartas commented 4 years ago

Hi,

Thank you for the answer.

Would it be possible to show how the inversion could be made to retrieve XYZ coordinates from MeshIO.cpp? Especially to get x and z coordinates.

I am using the command line and have very little knowledge of C++.

petrasvestartas commented 4 years ago

Is it mathematically possible to get back XYZ coordinates from UV spherical ones?

rohan-sawhney commented 1 year ago

Spherical positions are exported in place of the original mesh