+/*---------- noncircular rim cost ----------*/
+
+double noncircular_rim_cost(const Vertices vertices) {
+ int vy,vx,v;
+ double cost= 0.0;
+
+ FOR_RIM_VERTEX(vy,vx,v) {
+ double oncircle[3];
+ /* By symmetry, nearest point on circle is the one with
+ * the same angle subtended at the z axis. */
+ oncircle[0]= vertices[v][0];
+ oncircle[1]= vertices[v][1];
+ oncircle[2]= 0;
+ double mult= 1.0/ magnD(oncircle);
+ oncircle[0] *= mult;
+ oncircle[1] *= mult;
+ double d2= hypotD2(vertices[v], oncircle);
+ cost += d2*d2;