Hi there,

I am trying to understand an algorithm for relaxation of polgons on a sphere ( to resolve overlap or foldover),

The algorithm computes 'displacement' values for each vertex in the mesh based on it's 2-ring neighbours (degree 2) based on its neighbour vertices.

The algorithm says the following:


__________________________________________________ __________________________________

(for each vertex i in mesh)

neighbours[] = getNeighbours(i);
weight = 0.0;
displacements[i] = new Vector (0,0,0);
..........

for(each neighbour[j] of vertex i){

if( j not connected to flipped polygon)

Vector tmpV = j - i //calcualting a vector between j and i ??

displacements[i] += tmpV*tmpV.length()
weight += tmpV.lengthSquared() }


...........

displacements[i] /= weight;


__________________________________________________ _____________________________________


I cannot work out what the lines will actually do in relation to the algorithm:

displacements[i] += tmpV*tmpV.length()
weight += tmpV.lengthSquared()

What will it calulate in regard to the displacement (new location for vertex i to move to resolve the foldover), or how does it resolve the foldover based on these lines?

I understand vector lengths now and what they indicate but cannot work out what those two lines do.

I think j-i calculates a vector location between these two points, is that right?

displacements[i] /= weight, obviously finds the average weight based on all neighbours.

Any help you could provide would be great.

Many thanks
Dan