From: Ian Jackson Date: Thu, 9 Oct 2008 23:30:13 +0000 (+0100) Subject: attempts to fix 125; really need to combine edge length variation and bending costs X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=moebius2.git;a=commitdiff_plain;h=392a9a86486239e475b899ed648d21efa5749415 attempts to fix 125; really need to combine edge length variation and bending costs --- diff --git a/energy.c b/energy.c index 308aebf..9bd66e3 100644 --- a/energy.c +++ b/energy.c @@ -59,7 +59,21 @@ static const CostContribution costs[]= { COST( 1e18, noncircular_rim_cost) #endif -#if XBITS>=5 /* nonsense follows but never mind */ +#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) @@ -289,6 +303,32 @@ double edge_length_variation_cost(const Vertices vertices, int section) { 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]) { diff --git a/minimise.h b/minimise.h index c2e13e7..c611b89 100644 --- a/minimise.h +++ b/minimise.h @@ -23,6 +23,7 @@ extern const double edge_angle_cost_circcircrat; double line_bending_cost(const Vertices vertices, int section); double noncircular_rim_cost(const Vertices vertices, int section); double edge_length_variation_cost(const Vertices vertices, int section); +double prop_edge_length_variation_cost(const Vertices vertices, int section); double rim_proximity_cost(const Vertices vertices, int section); double edge_angle_cost(const Vertices vertices, int section); double small_triangles_cost(const Vertices vertices, int section);