summaryrefslogtreecommitdiff
path: root/meme
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2015-03-14 11:36:54 (GMT)
committerWerner Almesberger <werner@almesberger.net>2015-03-14 11:36:54 (GMT)
commitade67694d590b069603590c5f9bb73bd464634d7 (patch)
treea0d3a29bd41c5447e04ec4f0083cc58d421c3deb /meme
parent5063fcc259c3f5c485ade53ea2a1b1882bec2d30 (diff)
downloadmisc-ade67694d590b069603590c5f9bb73bd464634d7.zip
misc-ade67694d590b069603590c5f9bb73bd464634d7.tar.gz
misc-ade67694d590b069603590c5f9bb73bd464634d7.tar.bz2
meme/slice.c: scale plane coordinates; fix typo in "solve"
Diffstat (limited to 'meme')
-rw-r--r--meme/slice.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/meme/slice.c b/meme/slice.c
index 8bfbd1e..9bf2ce5 100644
--- a/meme/slice.c
+++ b/meme/slice.c
@@ -77,7 +77,7 @@ static bool solve(const struct vertex *va, const struct vertex *vb, double *res)
* m * t + a = 0
*/
- m = cx * dx + cx * dy - dz;
+ m = cx * dx + cy * dy - dz;
a = cx * va->x + cy * va->y - va->z + z0;
if (fabs(m) < EPSILON)
@@ -150,20 +150,19 @@ static void slice_load_file(FILE *file)
int lineno = 0;
char buf[1024];
int n;
- double zoff;
+ double x, y, z, zoff;
p = alloc_type(struct point);
while (fgets(buf, sizeof(buf), file)) {
lineno++;
if (*buf == '#')
continue;
- n = sscanf(buf, "%lf %lf %lf %lf\n",
- &p->x, &p->y, &p->z, &zoff);
+ n = sscanf(buf, "%lf %lf %lf %lf\n", &x, &y, &z, &zoff);
switch (n) {
case -1:
continue;
case 4:
- p->z += zoff;
+ z += zoff;
/* fall through */
case 3:
break;
@@ -172,6 +171,9 @@ static void slice_load_file(FILE *file)
exit(1);
}
+ p->x = x * 1000;
+ p->y = y * 1000;
+ p->z = z * 1000;
p->next = points;
points = p;
p = alloc_type(struct point);