chiark / gitweb /
curveopt: wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Apr 2018 21:59:26 +0000 (22:59 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Apr 2018 21:59:26 +0000 (22:59 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
curveopt.py

index ab02a8252426a5ab6229ca9578ba77bdd20269ef..b0e725c98b89f08f1bf53b759dbfcda302ad9dea 100644 (file)
@@ -4,8 +4,10 @@ from __future__ import print_function
 import numpy as np
 from numpy import cos, sin
 
+import six
 import sys
 import subprocess
+import math
 
 from moedebug import *
 from moenp import *
@@ -40,7 +42,7 @@ class OptimisedCurve():
     try:
       subproc = findcurve_subprocs[nt]
     except KeyError:
-      cl = ['./findcurve', '%d' % nt, '%.18g' % findcurve_epsilon]
+      cl = ['./findcurve', '%d' % (nt+1), '%.18g' % findcurve_epsilon]
       dbg('STARTING FINDCURVE %s' % cl)
       subproc = subprocess.Popen(
         cl,
@@ -84,7 +86,21 @@ class OptimisedCurve():
 
       findcurve_result = l
 
-    oc._result = np.reshape(findcurve_result, (3,-1))
+    oc.nt = nt
+    oc._result = np.reshape(findcurve_result, (-1,3), 'C')
+    dbg(repr(oc._result))
+
+    vdbg().curve( oc.point_at_t )
 
   def point_at_it(oc, it):
+    dbg(repr((it,)))
     return oc._result[it]
+
+  def point_at_t(oc, t):
+    itd = t * oc.nt
+    it0 = int(math.floor(itd))
+    it1 = int(math.ceil(itd))
+    p0 = oc.point_at_it(it0)
+    p1 = oc.point_at_it(it1)
+    return p0 + (p1-p0) * (itd-it0)
+