aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2018-09-20 14:12:48 -0500
committertlatorre <tlatorre@uchicago.edu>2018-09-20 14:12:48 -0500
commit378ecbc7af093382ed6b4faa4ceb645de1f00f1d (patch)
tree72b85254f6ff3c4741c3885f31643ad0fcd8ace8 /src
parent84ceeeac9ae55cdb0496505c9005daa28c5d977d (diff)
downloadsddm-378ecbc7af093382ed6b4faa4ceb645de1f00f1d.tar.gz
sddm-378ecbc7af093382ed6b4faa4ceb645de1f00f1d.tar.bz2
sddm-378ecbc7af093382ed6b4faa4ceb645de1f00f1d.zip
make sure direction vector is normalized in path_eval()
Diffstat (limited to 'src')
-rw-r--r--src/path.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/path.c b/src/path.c
index 2083dc1..9634479 100644
--- a/src/path.c
+++ b/src/path.c
@@ -184,10 +184,17 @@ void path_eval(path *p, double s, double *pos, double *dir, double *T, double *t
*T = interp1d(s,p->s,p->T,N);
*t = interp1d(s,p->s,p->t,N);
+ /* Technically we should be interpolating between the direction vectors
+ * using an algorithm like Slerp (see https://en.wikipedia.org/wiki/Slerp),
+ * but since we expect the direction vectors to be pretty close to each
+ * other, we just linearly interpolate and then normalize it. */
+
dir[0] = interp1d(s,p->s,p->dx,N);
dir[1] = interp1d(s,p->s,p->dy,N);
dir[2] = interp1d(s,p->s,p->dz,N);
+ normalize(dir);
+
*theta0 = p->theta0;
}