# linear combination of vertices vs. normals

14 replies to this topic

### #1mankind

New Member

• Members
• 8 posts

Posted 20 April 2011 - 09:33 PM

Hi,

Is it possible to prove that if a new vertex is produced by linearly combining two other vertices, its normal will be linear combination of the two normals?

It seems that way experimentally.

Thanks!

### #2imerso

Senior Member

• Members
• 431 posts
• LocationBrasil

Posted 20 April 2011 - 10:33 PM

The average of the two normals, you mean?

### #3}:+()___ (Smile)

Member

• Members
• 169 posts

Posted 20 April 2011 - 10:43 PM

It is not true if neighbour vertices have different weighting factor.

For example, Mesh1 & Mesh2 have only vertical normals while blended mesh not:

Sorry my broken english!

### #4mankind

New Member

• Members
• 8 posts

Posted 20 April 2011 - 10:48 PM

Yes, I mean let:
v1 be on mesh1
v2 be on mesh2
and create mesh3 where v3 = 0.5 * (v1+v2)
under which conditions n3 = 0.5*(n1 + n2) ?

### #5mankind

New Member

• Members
• 8 posts

Posted 20 April 2011 - 10:50 PM

### #6Reedbeta

DevMaster Staff

• 5305 posts
• LocationBellevue, WA

Posted 21 April 2011 - 12:06 AM

The blended mesh is created by linearly interpolating corresponding verts of Mesh1 and Mesh2, but the interpolation factor is not always 0.5, as it varies between verts (from 0 on the left to 1 on the right). In this case linearly interpolating the normals would give the wrong result.

Even if the interpolation factor is constant over the whole mesh, I do not think it completely works. It may give a good approximation in many cases however.
reedbeta.com - developer blog, OpenGL demos, and other projects

### #7mankind

New Member

• Members
• 8 posts

Posted 21 April 2011 - 04:07 AM

Right the linear interpolation is constant over the whole mesh. Can someone identify the conditions under which that works?

What are the assumptions that are made in such a case?

Thanks

### #8}:+()___ (Smile)

Member

• Members
• 169 posts

Posted 21 April 2011 - 01:01 PM

Mathematically, linear interpolation of normals is incorrect even in case of constant blending factor.

Consider interpolation between triangles {(0,0,0); pt1; pt2} and {(0,0,0); pt1+d1; pt2+d2}. Unnormalized normals will be cross(pt1, pt2) and cross(pt1+d1, pt2+d2) correspondingly.

With interpolation factor t triangle becomes {(0,0,0); pt1+t*d1; pt2+t*d2}. Right normal for this triangle is

cross(pt1+t*d1, pt2+t*d2) = cross(pt1, pt2) + t*cross(pt1, d2) + t*cross(d1, pt2) + t*t*cross(d1, d2).

Interpolated normal diverges from that expression in last term, simple linear interpolation gives t*cross(d1, d2) instead of t*t*cross(d1, d2).

In case of normalized normals expressions will be more heavy but not mathematically correct either.
Sorry my broken english!

### #9rouncer

Senior Member

• Members
• 2718 posts

Posted 21 April 2011 - 03:00 PM

x3=(x1+x2)/2
y3=(y1+y2)/2
z3=(z1+z2)/2
(renormalize 3)
doesnt get any more complex when your subdividing a triangle.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #10mankind

New Member

• Members
• 8 posts

Posted 21 April 2011 - 07:20 PM

Could you explain that--how does it relate to normals?

rouncer said:

x3=(x1+x2)/2
y3=(y1+y2)/2
z3=(z1+z2)/2
(renormalize 3)
doesnt get any more complex when your subdividing a triangle.

### #11mankind

New Member

• Members
• 8 posts

Posted 21 April 2011 - 07:24 PM

I wonder if it is the correct way to define that problem. I am thinking about that as having a point p1 on one mesh and a point p1+d1 on another mesh and producing p1' = p1 + t*(p1+d1). When normals are calculated need to take triangle around p1 to get n1 and triangle around (p1+d1) to get n2. It doesn't seem to be the same as stretching the original triangle. Is it correct?

'}:+()___ [Smile said:

']Mathematically, linear interpolation of normals is incorrect even in case of constant blending factor.

Consider interpolation between triangles {(0,0,0); pt1; pt2} and {(0,0,0); pt1+d1; pt2+d2}. Unnormalized normals will be cross(pt1, pt2) and cross(pt1+d1, pt2+d2) correspondingly.

With interpolation factor t triangle becomes {(0,0,0); pt1+t*d1; pt2+t*d2}. Right normal for this triangle is

cross(pt1+t*d1, pt2+t*d2) = cross(pt1, pt2) + t*cross(pt1, d2) + t*cross(d1, pt2) + t*t*cross(d1, d2).

Interpolated normal diverges from that expression in last term, simple linear interpolation gives t*cross(d1, d2) instead of t*t*cross(d1, d2).

In case of normalized normals expressions will be more heavy but not mathematically correct either.

### #12mankind

New Member

• Members
• 8 posts

Posted 21 April 2011 - 08:13 PM

I think this is the derivation:

p1 is the point on mesh1 and p2=p1+d is the point on mesh2.
n1 = p1 x (p1+v) --> this basically assumes that there is a dense mesh
n2 = (p1+d) x (p1+d+v) ---> this assumes again density, that the neigh point on mesh2 is close by v to p2.

then the new point p = p1+ t*(p1+d) and its normal will be
n = (p1+t*(p1+d)) x (p1+t*(p1+d)+v)
= (p1+t*(p1+d)) x v
= n1 + t*n2

what do you guys say?

mankind said:

I wonder if it is the correct way to define that problem. I am thinking about that as having a point p1 on one mesh and a point p1+d1 on another mesh and producing p1' = p1 + t*(p1+d1). When normals are calculated need to take triangle around p1 to get n1 and triangle around (p1+d1) to get n2. It doesn't seem to be the same as stretching the original triangle. Is it correct?

### #13}:+()___ (Smile)

Member

• Members
• 169 posts

Posted 21 April 2011 - 09:13 PM

mankind said:

p1 is the point on mesh1 and p2=p1+d is the point on mesh2.
n1 = p1 x (p1+v) --> this basically assumes that there is a dense mesh
What is 'v'? For correct definition of normal we need at least 3 points: n1 = (p2-p1) x (p3-p1).

mankind said:

then the new point p = p1+ t*(p1+d) and its normal will be
Wrong formula, must be p = (1-t)*p1 + t*(p1+d) = p1 + t*d.

A normal is nonlinear (quadratic in simple case) function of points position. Simple interpolation works only in case of linear functions.
Sorry my broken english!

### #14mankind

New Member

• Members
• 8 posts

Posted 21 April 2011 - 09:21 PM

It doesn't matter what interpolation, I just formulated exactly the same way as you did to be consistent.

I assumed each triangle is consists of 0,0,0 p1 and p1+v

I'm trying to say that maybe the way you defined it is not completely correct--since it's not like we're stretching the triangle when we interpolate but we take other points (which are close to the interpolated point) to get the normal.

'}:+()___ [Smile said:

']What is 'v'? For correct definition of normal we need at least 3 points: n1 = (p2-p1) x (p3-p1).

Wrong formula, must be p = (1-t)*p1 + t*(p1+d) = p1 + t*d.

A normal is nonlinear (quadratic in simple case) function of points position. Simple interpolation works only in case of linear functions.

### #15}:+()___ (Smile)

Member

• Members
• 169 posts

Posted 22 April 2011 - 09:30 AM

Well, 'v' isn't constant between triangles, so interpolated normal will be
n = (p1 + t*d) x (v + t*dv) != n1 + t*(n2-n1).
Error is t*(1-t)*[d x dv] -- then rotation and deformation of each triangle is small compared with its size, error is small also.

Interpolation is essentially stretching triangles and normals usually calculated as weighted sum of neighbour triangle normals. But even if our meshes are approximation of some mathematic surfaces and normals calculated from exact derivatives, error will be the same order as normal is nonlinear function of that derivatives.
Sorry my broken english!

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users