I have a programming problem which is really a math problem.
No.14128918 ViewReplyOriginalReport
Quoted By: >>14128941 >>14128970 >>14129013 >>14129021 >>14129398
So I'm going to phrase it like a math problem because I need help and haven't found anybody who has done this before.
I have a point in 3D space P,
and a mesh, a non-discrete set of points in 3D space, "X"
The faces of X are triangles formed by some 3 elements of X.
Every point in X has an attached 2D vector "uv." When every uv is laid out onto a 2D space called UV space.
A 2D image can be mapped onto the uv points, then the triangular faces form planes for the image to stretch across and create a "textured" object.
For any finite set X, how do I find a coordinate in UV space C such that when C is wrapped onto X, the resulting position Q is the closest point to P on any face of X?
Before I wrote it out in big-boy math words this problem didn't sound so complicated. But, after a couple days of hammering it out in code I can't find a system that works.
I have an """""approximation""""" where I loop through every element of X and find the 3 closest to P, scale their distances from P such that they sum to one, and then sum up the uv's of the elements of X, multiplying each by the scaled distance of their associated point.
I have seen this done for a plane - https://stackoverflow.com/questions/18663755/how-to-convert-a-3d-point-on-a-plane-to-uv-coordinates
I have seen something similar to an inversion of this problem - https://computergraphics.stackexchange.com/questions/8470/how-to-get-the-3d-position-for-the-point-with-0-0-uv-coordinates
In theory, I could get triangle P is closest to with existing functions in my library and then convert that triangle to a uv plane and use the first solution above. It's what I'm working out now. Progress is slow and unsure.
I have a point in 3D space P,
and a mesh, a non-discrete set of points in 3D space, "X"
The faces of X are triangles formed by some 3 elements of X.
Every point in X has an attached 2D vector "uv." When every uv is laid out onto a 2D space called UV space.
A 2D image can be mapped onto the uv points, then the triangular faces form planes for the image to stretch across and create a "textured" object.
For any finite set X, how do I find a coordinate in UV space C such that when C is wrapped onto X, the resulting position Q is the closest point to P on any face of X?
Before I wrote it out in big-boy math words this problem didn't sound so complicated. But, after a couple days of hammering it out in code I can't find a system that works.
I have an """""approximation""""" where I loop through every element of X and find the 3 closest to P, scale their distances from P such that they sum to one, and then sum up the uv's of the elements of X, multiplying each by the scaled distance of their associated point.
I have seen this done for a plane - https://stackoverflow.com/questions/18663755/how-to-convert-a-3d-point-on-a-plane-to-uv-coordinates
I have seen something similar to an inversion of this problem - https://computergraphics.stackexchange.com/questions/8470/how-to-get-the-3d-position-for-the-point-with-0-0-uv-coordinates
In theory, I could get triangle P is closest to with existing functions in my library and then convert that triangle to a uv plane and use the first solution above. It's what I'm working out now. Progress is slow and unsure.