chiark / gitweb /
curveopt: wip, observe a bug
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Apr 2018 22:54:55 +0000 (23:54 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Apr 2018 22:55:00 +0000 (23:55 +0100)
This algorithm encourages a segment with a curve either side of it to
be shorter than its neighbours.  In this test case there is another
bug: the cp[1] (F) and cp[2] (G) vectors are wrong, exaggerating the
effect of the bug.

To fix the wrong encouragement bug, I think we will have to split the
penalty for curvature from the penalty for density variation.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
curveopt.py

index 5ebe1661c5f9f35c06dbde6fa5c584a4ce8f9e81..12d962512b8a484bc83825bd62cdd679ff5aa4c7 100644 (file)
@@ -29,8 +29,8 @@ class OptimisedCurve():
     for end in (False,True):
       ei = nt if end else 0
       fi = nt-1 if end else 1
-      cp0i = 0 if end else 3
-      cp1i = 1 if end else 2
+      cp0i = 3 if end else 0
+      cp1i = 2 if end else 1
       e = np.array(cp[cp0i])
       ef_dirn = unit_v(cp[cp1i] - cp[cp0i])
       ef_len = np.linalg.norm(np.array(fc_input[fi]) - np.array(fc_input[ei]))