From e57dd0a26b305c93dbb39202cdc604cacc614ee2 Mon Sep 17 00:00:00 2001 From: Don Cross Date: Sun, 19 Dec 2021 21:33:34 -0500 Subject: [PATCH] Added aim test sanity check in raytracer. Instead of just printing both unit vectors that should be the same, actually check that they point the same direction with a very tight tolerance. --- demo/c/raytrace/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/demo/c/raytrace/main.cpp b/demo/c/raytrace/main.cpp index aecb557a..d7efad02 100644 --- a/demo/c/raytrace/main.cpp +++ b/demo/c/raytrace/main.cpp @@ -188,6 +188,13 @@ int JupiterImage(const char *filename, int width, int height, astro_time_t time, jupiter.y / sph.dist, jupiter.z / sph.dist); + const double diff = (aimTest - Vector(jupiter.x/sph.dist, jupiter.y/sph.dist, jupiter.z/sph.dist)).Magnitude(); + if (diff > 1.0e-15) + { + fprintf(stderr, "FAIL aim test: diff = %le\n", diff); + return 1; + } + scene.SetAimer(&aimer); scene.SaveImage(filename, (size_t)width, (size_t)height, zoom, 4);