diff --git a/src/madl_dynmap.mad b/src/madl_dynmap.mad index a6a200a9d..4bbe11f7e 100644 --- a/src/madl_dynmap.mad +++ b/src/madl_dynmap.mad @@ -270,7 +270,8 @@ M.translate = translate -- Changeref (generic patch, lw_>0: RT, lw_<0: TR) function M.changeref (elm, m, lw_) -- unchecked - local lw = lw_ or 1 + local sdir, edir in m + local lw = (lw_ or 1)*sdir -- for trackone, sdir is not placed into lw local dx, dy, ds, dphi, dpsi in elm local dthe = elm.dtheta local trn = abs(dx )+abs(dy )+abs(ds ) >= minlen @@ -285,21 +286,21 @@ function M.changeref (elm, m, lw_) -- -- rotate if rot and lw > 0 then - yrotation( dthe, m, 1) - xrotation(-dphi, m, 1) - srotation( dpsi, m, 1) + yrotation( dthe, m, edir) + xrotation(-dphi, m, edir) + srotation( dpsi, m, edir) end -- translate if trn then - translate({dx=dx, dy=dy, ds=ds}, m, lw) + translate({dx=dx, dy=dy, ds=ds}, m, 1) -- translate does everything end -- rotate if rot and lw < 0 then - srotation( dpsi, m, -1) - xrotation(-dphi, m, -1) - yrotation( dthe, m, -1) + srotation( dpsi, m, -edir) + xrotation(-dphi, m, -edir) + yrotation( dthe, m, -edir) end m.atdebug(elm, m, lw_, 'changeref:1')