   Interpolating vertex normals without barycentric coords
  Hello everybody,this is my first post.I need to get the interpolated normal of a point P within a triangle and through some research found the barycentric coordinates to be the right tool to use. This thread was also very useful for the purpose:http://www.gamedev.net/community/forums/topic.asp?topic_id=451357Of course it works, but I have a question.Before using barycentric coordinates I was obtaining the interpolated normal another way.What I want is a linear convex combination of the normals at vertices V1, V2, V3:(1) a*N1 + b*N2 + c*N3 = N  (2) with a+b+c=1 and 0 <= a,b,c <= 1The three triangle vertices are independent vectors and thus form a basis. Then I can weigh each vertex normal according to the projection of point P over each vertex, that is simply perform a basis change bringing the point P over this new basis:a = (P dot V1) / |V1|b = (P dot V2) / |V2|c = (P dot V3) / |v3|and then divide a, b, c by (a+b+c) to satisfy condition (2).Finally, after computing (1) I can normalize N to have a unit-length normal.What's wrong with this approach? I find it perfectly valid and can't justify passing to barycentric coordinates if not for performance reasons (in case).In this moment I'm not interested in performance but in the maths.Thanks in any case,happy to take part to the forums   
  A linear combination should work as that what both GL and DirectX pipeline does for smooth shading. The weights are pretty much the barycentric coordinates weight so the equate to the same thing. Actually it will be more like bilinear interpolation since its both done in the plane of the triangle face.   ;  bdisraeli,  Right off the bat, one reason to use barycentric coordinates is to free yourself from global similarity transforms.  In your approach, you treat vertex coordinates as vectors, but they are not; they are points.  Imagine that V0 is at (0,0,0).  Then your approach will result in a divide by 0.  The second problem with your approach, working through an example, is that it doesn't provide the right results.  Take the following example.V0 = (1, 0, 0)V1 = (2, 1, 0)V2 = (3, 0, 0)P =  (2, 0.5, 0)Now, instead of the normal, assume that we wish to simply express the coordinate of the point P using your system.  That is, we wish that (a * V0) + (b * V1) + (c * V2) = P.  Let's run through the equations:a = (P dot V1) / |V1| = ((2, 0.5, 0) dot (1, 0, 0)) / || (1, 0, 0) ||  = 2 / 1 = 2b = (P dot V2) / |V2| = ((2, 0.5, 0) dot (2, 1, 0)) / || (2, 1, 0) ||  = 4.5 / sqrt(5) = 2.01246117974981072677c = (P dot V3) / |V3| = ((2, 0.5, 0) dot (3, 0, 0)) / || (3, 0, 0) ||  = 6 / 3 = 2let D = a + b + c = 6.01246117974981072677 . Normalizing a, b and c we get:a = .33264248037660071518b = .33471503924679856962c = .33264248037660071518now, we try to express P in these coordinates.  We get:First the x co-ordinateP(x) = (.33264248037660071518 * 1) + (.33471503924679856962 * 2) + (.33264248037660071518 * 3) = 2 So far it looks good; now the y co-ordinate:P(y) = (.33264248037660071518 * 0) + (.33471503924679856962 * 1) + (.33264248037660071518 * 0) = .33471503924679856962This is clearly wrong.  However, if you carry out the same procedure using barycentric coordinates (lambda_1, lambda_2 and lambda_3) in place of your a, b and c, you'll get the right answer.  I've gone ahead and worked out the lambdas.  They are:lambda_1 = 0.25lambda_2 = 0.5lambda_3 = 0.25so you get:P(x) = (0.25 * 1) + (0.5 * 2) + (0.25 * 3) = 2and P(y) = (0.25 * 0) + (0.5 * 1) + (0.25 * 0) = 0.5The interpolation of the coordinate functions was just an example.  The same problem will arise when you attempt to interpolate any function (like the normal) across the triangle using your method.  It doesn't jump out to me (besides the degenerate case I pointed out at the beginning) exactly what the logical flaw is in your method, but I'll let you know if it comes to me.Cheers,Rob;  Hello,thank you for your replies and your time.cgrant: I agree but the fact is that a linear combination is not sufficient; we need to impose additional constraints on the coefficients to stay within the triangle, that is, a linear convex combination of the vertices is what we are looking for. And as I understand it this combination shall be unique. These coefficients are, in fact, the barycentric coordinates of the point; but I don't get the pitfall in my change of basis approach.gfxnomad:Thanks for the extensive response and for the experiments. I agree with all you say. I am using barycentric coordinates at the moment but why projecting over the vertices treated as vectors doesn't tehoretically work is currently beyond me. I suspect I'm disregarding some very basic notion here...   ;  OK,well I see my mistake now, it is very simple indeed.Theoretically, the change-of-basis approach is correct (let us set aside the advantages of barycentric coordinates over this approach for a moment).The problem is that I am not performing the change of basis correctly. Projecting in a perpendicular fashion (which is obtained using the dot product) the point over the basis is right only for an orthogonal basis (the XYZ axes or the Fourier basis for example).For a generic, non-orthogonal basis the change of basis is more complicated. I'll omit the details for now but I'll post the correct results at a later time. In any case I shall stick to barycentric coordinates for the future...Thanks a lot for your help!   