View Full Version : Find 2D UV coordinate for 3D XYZ point inside polygon (arbitrarily UV mapped)
Kuroyume0161 06172005, 08:34 PM Find 2D UV coordinate for 3D XYZ point inside polygon (arbitrarily UV mapped)?
Given a point 'p' on the surface of a polygon in 3D space and a set of UV points for the polygon's vertices, how would one determine the UV coordinate of 'p' with only this information? There is no particular procedural mapping expected (the UV points may have been manipulated by the user or some arbitrary functions).
Thanks,


nurcc
06172005, 10:28 PM
I have a solution for triangles, that may be enough for you. The true answer for nsided polygons depends on the method your renderer is using to interpolate the UV coordinates. For triangles, barycentric is the most common, and for quadrangles, bilinear is common.
Anyhow, here's what I did when I needed to do this for triangles. I'd either assume that P is in the plane defined by the triangle, or project it to that plane. Then I'd have the vertices of the triangle ABC, with P in the triangle. I'd compute the area of the 3 triangles ABP BCP and CAP. Then the barycentric coordinates of the points A B and C are the areas of the opposite triangles, divided by the sum of the areas. In other words, bary(A) = Area(BCP)/(SumOfAreas). Then use barycentric interpolation of the UVs to find the correct interpolated UV coordinate of P.
Let me know if you'd like more details on how to compute or use barycentric coordinates..
Kuroyume0161
06182005, 08:14 AM
Thanks, nurcc.
This isn't a question on my behalf but on someone else's. I tried to explain that nonlinear interpolation was involved, but couldn't find the correct terms to search on, so asked here.
I'll pass your response on and use that to get more information if he still needs it.
CGTalk Moderation
06182005, 08:14 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©20002015, Jelsoft Enterprises Ltd.