summaryrefslogtreecommitdiff
path: root/meme/slice.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2015-03-15 07:00:40 (GMT)
committerWerner Almesberger <werner@almesberger.net>2015-03-15 07:00:40 (GMT)
commit1e6ad8a5e648785e6ef0ce62055811aa46520bf5 (patch)
tree6084ff33cfcebb2c4a9f26293537a46e7a81cac3 /meme/slice.c
parent83e28d001844f160bfe73a35dd03868a9971756a (diff)
downloadmisc-1e6ad8a5e648785e6ef0ce62055811aa46520bf5.zip
misc-1e6ad8a5e648785e6ef0ce62055811aa46520bf5.tar.gz
misc-1e6ad8a5e648785e6ef0ce62055811aa46520bf5.tar.bz2
meme/: add global z offset; prettify plane diagnostic; fix warning limit
Diffstat (limited to 'meme/slice.c')
-rw-r--r--meme/slice.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/meme/slice.c b/meme/slice.c
index 9618249..3b41965 100644
--- a/meme/slice.c
+++ b/meme/slice.c
@@ -40,7 +40,9 @@ static struct point *points = NULL;
/* ----- Slicing plane ----------------------------------------------------- */
-static double z0, cx, cy; /* z = cx * x + cy * y + z0 */
+/* z(x, y) = cx * x + cy * y + z0 */
+
+static double cx, cy, z0;
static void slice_plane(void)
@@ -86,7 +88,8 @@ static void slice_plane(void)
gsl_vector_free(y);
gsl_vector_free(c);
-fprintf(stderr, "cx %g cy %g z0 %g\n", cx, cy, z0);
+ fprintf(stderr, "plane: z(x, y) = %g * x + %g * y + %g\n",
+ cx, cy, z0 / 1000);
}
@@ -191,6 +194,7 @@ static void step(void (*fn)(double x, double y, double z, bool last),
if (e > d) {
if (warnings < MAX_WARN) {
fprintf(stderr, "e > d: %f, %f; dz = %f\n", e, d, dz);
+ warnings++;
} else if (warnings == MAX_WARN) {
fprintf(stderr, "...\n");
warnings++;
@@ -256,6 +260,7 @@ static void slice_load_file(FILE *file)
char buf[1024];
int n;
double x, y, z, zoff;
+ double zglobal = 0;
p = alloc_type(struct point);
while (fgets(buf, sizeof(buf), file)) {
@@ -266,6 +271,9 @@ static void slice_load_file(FILE *file)
switch (n) {
case -1:
continue;
+ case 1:
+ zglobal = x * 1000;
+ continue;
case 4:
z += zoff;
/* fall through */
@@ -284,6 +292,9 @@ static void slice_load_file(FILE *file)
p = alloc_type(struct point);
}
free(p);
+
+ for (p = points; p; p = p->next)
+ p->z += zglobal;
}