diff --git a/src/modules/interface/pptraj.h b/src/modules/interface/pptraj.h index ed0b8bce8..0ae10f762 100644 --- a/src/modules/interface/pptraj.h +++ b/src/modules/interface/pptraj.h @@ -137,6 +137,7 @@ bool is_traj_eval_valid(struct traj_eval const *ev); // evaluate a single polynomial piece struct traj_eval poly4d_eval(struct poly4d const *p, float t); +// rotate and then translate a traj_eval object void traj_eval_transform(struct traj_eval *ev, struct vec shift, float rotation); // ----------------------------------// diff --git a/src/modules/src/pptraj.c b/src/modules/src/pptraj.c index 65d6fac00..0fe297a07 100644 --- a/src/modules/src/pptraj.c +++ b/src/modules/src/pptraj.c @@ -331,10 +331,12 @@ struct traj_eval poly4d_eval(struct poly4d const *p, float t) void traj_eval_transform(struct traj_eval *ev, struct vec shift, float rotation) { + struct mat33 rotator = mrotz(normalize_radians(rotation)); + // rotate position, velocity, acceleration - ev->pos = mvmul(mrotz(normalize_radians(rotation)), ev->pos); - ev->vel = mvmul(mrotz(normalize_radians(rotation)), ev->vel); - ev->acc = mvmul(mrotz(normalize_radians(rotation)), ev->acc); + ev->pos = mvmul(rotator, ev->pos); + ev->vel = mvmul(rotator, ev->vel); + ev->acc = mvmul(rotator, ev->acc); // shift ev->yaw += normalize_radians(rotation);