2

I need to find a way to parametrise $\mathbb{R^3}$ coordinates relative to a mesh, which is a deformed $UV$ sphere with triangular faces. Every vertex on the mesh has a $UV$ coordinate, and I want to associate every $\mathbb{R^3}-$ point with a coordinate ($u,v$, signed distance). So for instance, points on the mesh would simply be assigned $(u,v,0)$. If a point starts on the mesh at a vertex and then moves outwards by $1$ in the direction of the vertex normal, the new point should be assigned $(u,v,1)$. If a point starts on the mesh inside a face, its normal is a barycentric combination of the surrounding vertex normals, then $(u,v,1)$ is defined as above. Moving inwards gives a negative signed distance. It seems intuitive to me that this formulation assigns a coordinate to every point in $\mathbb{R^3}$, since it is like inflating the mesh until you reach any arbitrary point in $\mathbb{R^3}$. However, I have not been able to find an efficient (or any) way to compute this on an arbitrary $\mathbb{R^3}$ point for a given set of vertex positions. Can anyone see such a way, or is there another approach which is easier altogether?

EBartrum
  • 225

1 Answers1

1

This sounds like a computer graphics problem.

Suppose $P$ is the point you want to parametrize. Let $T$ be a triangle with vertices $x_1,x_2,x_3$, vertex normals $n_1,n_2,n_3$ and UV coordinates $u_1,u_2,u_3$. You want to find a point $X=ax_1+bx_2+(1-a-b)x_3$ with normal $N=an_1+bn_2+(1-a-b)n_3$ such that $N$ is parallel with the line $XP$. This will be the case if the cross product $C=N\times(P-X)=0$. The vector $C$ will have three components that are 2nd degree functions in $a$ and $b$ so you have to solve for $a$ and $b$. This is essentially solving for the intersection of three conics. Best to find an existing solver, but check out this question and answers: Algorithm: Intersection of two conics

Once you have this information, compute the signed distance $w$. And $(u,v)=au_1+bu_2+(1-a-b)u_3$, so the parametrization of $P$ with respect to $T$ is $(u,v,w)$.

It remains to choose a triangle $T$. Depending on how much the sphere is deformed, there may be more than one $(u,v,w)$ coordinate for a point. But your best bet should be to choose the triangle closest to $P$.

brainjam
  • 8,626
  • Many thanks for this detailed answer! This is what I was thinking, except that I had no idea how to approach solving for a and b. As you guessed, this is a graphics problem, and I need to make my solution efficient. For my point P, checking if Im in the conic for every triangle in the mesh is probably not going to be viable. So my idea is to check only the k nearest triangles, where nearest means nearest by triangle centre. Maybe there are cases where the correct triangle is not among these? In case its relevant, I know that any vertex is a member of at most 6 triangles. Does this make sense? – EBartrum Feb 19 '21 at 14:11
  • 1
    @EBartrum Much depends on the context of your problem. Is this coursework or practical? How deformed is deformed? How efficient is efficient? To get an intuition for the relationship between orthogonal projection and closest point take a look at papers like https://www.sciencedirect.com/science/article/pii/S2288430014500176 (this is for continuous surfaces) – brainjam Feb 19 '21 at 14:34
  • This is in deep learning context, Im learning the deformation on the fly by training a shape model. So I can make things easier by adding constraints on the learned mesh - for example, encouraging regular sized triangles, and a smooth surface. – EBartrum Feb 19 '21 at 14:37
  • 1
    For choosing the triangle you'll probably have to experiment with a few heuristics. I'd try either closest triangle, or maybe the neighbours of closest vertex. (does it even matter whether you find the absolute best triangle?) There's also https://computergraphics.stackexchange.com/ (especially the computational-geometry tag), where there may be people who have had more practical experience with this sort of thing. – brainjam Feb 19 '21 at 16:09
  • I dont think it needs to be the absolute best so long as Im consistent (this function should have as few discontinuities as possible). Im mainly trying to narrow the search to find a triangle satisfying the constraint for the point as fast as possible. Lastly would you agree with my intuition that using a morphed sphere mesh, this provides a parametrisation of every point in R3? – EBartrum Feb 19 '21 at 16:19
  • 1
    Yes, I’d agree. Offhand I’m not sure how I’d prove it, but it would be a topological or fixed point argument based on the continuity of your definition of normals, and not allowing pathological meshes. Of course the parametrizations would not necessarily be unique or continuous for non-convex deformations. – brainjam Feb 19 '21 at 17:55