Skip to content

Survey fixes #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/madl_esurv.mad
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ local fnil, bind3rd in MAD.gfunc
local errorf in MAD.utility
local minlen, minang in MAD.constant
local is_implicit in element.drift
local arc2cord in MAD.gmath
local arc2cord, arc2len in MAD.gmath

local abs, sin in math

Expand Down Expand Up @@ -177,7 +177,7 @@ local function track_thick (elm, m, fng_)
local ds in m
local angle in elm
local no_ang = abs(angle) < minang or fng_
m.el, m.ang = ds, angle*m.tdir
m.el, m.ang = fng_ and m.el or ds, angle*m.tdir

local inter, track, thick
if abs(ds) >= minlen then -- trick: driftonly+thick <=> thinonly+thin
Expand All @@ -197,8 +197,8 @@ local function fng_e1 (e, m, s)
local d = s*sdir
if d == -1 then
local e_ = {name=e.name, dx=elc*sin((e2-e1)/2), dy=0, ds=0}
yrotation(e2, m, -1) -- translation independant of direction
translate(e_, m, -1)
translate(e_, m, -1) -- translation independant of direction
yrotation(e2, m, -1)
elseif e1 ~= 0 then
yrotation(e1, m, -1)
end
Expand All @@ -209,8 +209,8 @@ local function fng_e2 (e, m, s)
local d = s*sdir
if d == 1 then
local e_ = {name=e.name, dx=elc*sin((e2-e1)/2), dy=0, ds=0}
translate(e_, m, -1) -- translation independant of direction
yrotation(e1, m, -1)
translate(e_, m, -1) -- translation independant of direction
elseif e2 ~= 0 then
yrotation(e2 , m, -1)
end
Expand All @@ -221,19 +221,21 @@ local fng_e = \e, m, s -> yrotation(e, m, -0.5)
local function track_rbend (elm, m)
local fng = nil -- default: curved rbend aka sbend with parallel pole faces

if elm.true_rbend then -- true rbend
local e1, e2, angle, l in elm
if e1 and e2 then -- MAD-like Wedge rbend
if elm.true_rbend then
local e1, e2, angle in elm
m.elc = arc2cord(m.ds, angle)
if e1 and e2 then -- MAD-like wedge rbend
fng = fng_e
m.el = m.elc
else -- true parallel rbend
m.elc = arc2cord(l, angle)
if e1 then
m.e1, m.e2 = e1, angle - e1
fng = fng_e1
else
m.e1, m.e2 = angle - e2, e2
fng = fng_e2
end
m.el = arc2len(m.ds, angle)
end
end

Expand Down