/* Relaxes the vertex v to a new position We will store v's new relaxed position as the oddVertexData We only relax non-boundary vertices PRE: v has an even generation v is not a boundary edge */ void TriangleMesh::relaxVertex(Vertex& v) { if (v.isBoundary()) return; Vertex::iterator vitr = v.current(); //The (elementwise) sum of the vertices around v. VertexData vertexSum; int vertexCounter = 0; for(; !vitr.isDone(); ++vitr) { vertexSum = vertexSum + vitr->next->vertex->getData(); ++vertexCounter; } //the combination value alpha, as determined by the sqrt(3) algorithm. float alpha = (4 - 2*cos(2*Globals::PI/vertexCounter) )/9.0f; //Save the new, relaxed value in the "odd" Vertex Data v.addOddData(v.getData()*(1-alpha) + vertexSum*(alpha/vertexCounter)); }