# Find point-face relation

## Recommended Posts

mfiorilli    100
Hi there,

This is my first post here.

Here is a picture of my problem: http://cgaddict.com/myproblem.jpg

I'm trying to find the position of a given point in relation to a face. At first we know the value of the point and face and need to record their relation, and then we only know the value of the face.

Beware that this is something that will be done on heavy geometry (20,000+ faces) and compiled in C++. I'm looking for the fastest solution possible, even if it's not TOTALLY accurate... or a way to control the quality versus speed.

Thanks!

##### Share on other sites
karwosts    840
I'm a bit confused what you describe as "the value of your face". What is this number? The average of all the vertices?

##### Share on other sites
mfiorilli    100
karwosts: I know absolutely all of my face. Each of it's vertex, it's normal, everything.

##### Share on other sites
karwosts    840
Yes, but your problem is just not well defined. You want to translate an object in relation to "your face", but this is meaningless. A "face" is not any meaningful geometric object, its just a collection of points.

If you have a quad centered at 0,0 and move one of the vertices 1000 miles away, how would you expect your point to move? This gets even more confusing if you're defining a face as 4 vertices, what happens if it is nonplanar? What if it's twisted over like a bow tie?

##### Share on other sites
mfiorilli    100
karwosts: I'm not sure if this is something that will do any difference but the face's vertex won't be traveling a lot from each others. It will very rarely go in crazy extreme deformations. But if it ends up by flipping it won't work at all for what I need anyway.

On the other hand, I was thinking of decomposing the face into a triangle, taking only 3 of its vertex. Maybe that way there would be a formula to allow the relation between the triangle and the point?

I was also wondering if there's a way to find the relation between two constant vectors and one that we have to find (exactly like the face and point). At first we would know all of our three vectors, and after we will have to guess our mystery vector based on it's relation previously found with the two other vectors.

I'm 100% sure there's a way to do that, I just don't know where to start and the best way for quality and speed.

##### Share on other sites
jyk    2094
As long as the face remains rigid, there's no problem (that I can see at least); you can easily create a (partially arbitrary) coordinate frame for your face, compute the local coordinates of the point relative to that frame, and then use that information to compute the new coordinates of the point as the face moves.

It's when the face deforms that things become more complicated, as previously noted. I'll ask my usual question: can you describe the exact problem that you're trying to solve? What do the faces represent? What do the points represent? And what's the purpose of having the point attempt to retain its initial configuration relative to the face?

##### Share on other sites
mfiorilli    100
jyk: Unfortunately, the face will never remain rigid.

The main idea is to create a wrap deformer. If you are familiar with 3D package such as Maya you probably know what I'm talking about. Otherwise, try to think about it this way: I have two geometry. Geometry A will deform and geometry B will follow the deformation of geometry A. In my case, both geometry have the same number of faces/vertex/edges and have the same configuration BUT their vertex are not at the same place. So basically, I want to wrap B onto A.