#endif
#if XBITS==4
+#define STOP_EPSILON 1.2e-4
+ COST( 3e5, line_bending_cost)
+ COST( 10e3, edge_length_variation_cost)
+ COST( 9.0e3, rim_proximity_cost) // 5e1 is too much
+ // 2.5e1 is too little
+ // 0.2e1 grows compared to previous ?
+ // 0.6e0 shrinks compared to previous ?
+
+// COST( 1e12, edge_angle_cost)
+ #define EDGE_ANGLE_COST_CIRCCIRCRAT (0.5/1.3)
+ COST( 1e18, noncircular_rim_cost)
+#endif
+
+#if XBITS==5
+#define STOP_EPSILON 1.2e-4
+ COST( 3e7, line_bending_cost)
+ COST( 10e2, prop_edge_length_variation_cost)
+ COST( 9.0e3, rim_proximity_cost) // 5e1 is too much
+ // 2.5e1 is too little
+ // 0.2e1 grows compared to previous ?
+ // 0.6e0 shrinks compared to previous ?
+
+// COST( 1e12, edge_angle_cost)
+ #define EDGE_ANGLE_COST_CIRCCIRCRAT (0.5/1.3)
+ COST( 1e18, noncircular_rim_cost)
+#endif
+
+#if XBITS>=6 /* nonsense follows but never mind */
#define STOP_EPSILON 1e-6
COST( 3e5, line_bending_cost)
COST( 10e2, edge_length_variation_cost)
int ci;
for (ci=0; ci<NPRECOMPS; ci++) {
- costs[ci].fn(vs->a, section);
+ precomps[ci](vs->a, section);
inparallel_barrier();
}
for (ci=0; ci<NCOSTS; ci++)
return cost;
}
+/*---------- proportional edge length variation ----------*/
+
+ /*
+ * Definition:
+ *
+ * See the diagram above.
+ * r
+ * cost = ( |PQ| - |QR| )
+ * Q,e
+ */
+
+double prop_edge_length_variation_cost(const Vertices vertices, int section) {
+ double cost= 0, exponent_r= 2;
+ int q, e,r, eback;
+
+ FOR_EDGE(q,e,r, OUTER) {
+ eback= edge_reverse(q,e);
+ double le= edge_lengths[q][e];
+ double leback= edge_lengths[q][eback];
+ double diff= le - leback;
+ double num= MIN(le, leback);
+ cost += pow(diff / (num + 1e-6), exponent_r);
+ }
+ return cost;
+}
+
/*---------- rim proximity cost ----------*/
static void find_nearest_oncircle(double oncircle[D3], const double p[D3]) {