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

index a0e44cbf1313eac4f16dd0a3060f7253ddea6c36..699e437158b5c30de5fa430b8a8436d11b98026c 100644 (file)
@@ -18,7 +18,7 @@ import symbolic
 findcurve_subprocs = { }
 
 class OptimisedCurve():
-  def __init__(hc, cp, nt):
+  def __init__(oc, cp, nt):
     db = DiscreteBezier(cp, nt, constructor=BezierSegment)
     fc_input = map(db.point_at_it, range(0, nt+1))
     for end in (False,True):
@@ -79,21 +79,9 @@ class OptimisedCurve():
       dbg('[%s] %s' % (l, commentary))
       commentary = ''
 
-      hc.findcurve_result = l[0:6]
-      #hc.findcurve_result = findcurve_start
-      hc.threshold = l[0]**2
-      hc.total_dist = hc.threshold + l[1]**2
-      #vdbg().curve( hc.point_at_t )
-
-  def point_at_t(hc, normalised_parameter):
-    dist = normalised_parameter * hc.total_dist
-    ours = list(hc.findcurve_result)
-    if dist <= hc.threshold:
-      ours[0] = sqrt(dist)
-      ours[1] = 0
-    else:
-      ours[1] = sqrt(dist - hc.threshold)
-    asmat = hc.func(*ours)
-    p = asmat[:,0]
-    p = augmatmultiply(hc.findcurve_basis, p)
-    return p
+      findcurve_result = l
+
+    oc._result = np.reshape(findcurve_result, (3,-1))
+
+  def point_at_ti(oc, ti):
+    return oc._result[ti]
index 32050acde23644aa4bf675cf8a8cba4358f699ee..077f31c06c5c6a8815fcb3b2246820846d21eee0 100644 (file)
@@ -33,8 +33,7 @@ static void prepare(double X[] /* startpoint */) {
 
 static double cb_Efunc(void *xp) {
   const double *X = xp;
-  double F[3], G[3];
-
+  DECLARE_F_G;
   CALCULATE_F_G;
 
   double e = 0;
@@ -71,9 +70,13 @@ static double cb_metric(void *xp, void *yp) {
 }
 
 static void printcore(const double *X) {
-  int i;
+  int i, j;
+  DECLARE_F_G;
+  CALCULATE_F_G;
   printf("[");
-  for (i=0; i<NX; i++) printf(" %.18g,", X[i]);
+  for (i=0; i<NP; i++)
+    for (j=0; j<3; j++)
+      printf(" %.18g,", POINT(i)[i]);
   printf(" ]\n");
 }
 
index a050b6a90918fce9bcb3b0945112d55f1c50140f..a64e128d99d5adec2aebc7e9eb8fc3acb35020b6 100644 (file)
@@ -191,6 +191,7 @@ def gen_prepare():
   cprintraw('')
 
 def gen_calculate_FG():
+  cprintraw('#define DECLARE_F_G double F[3], G[3];')
   cprint('#define CALCULATE_F_G')
   cassign_vector(F,'F','tmp_F')
   cassign_vector(G,'G','tmp_G')