Skip to content

Commit dbf4d99

Browse files
authored
Merge pull request #300 from jgray-19/survey_fixes
Survey fixes
2 parents b08134c + 5075781 commit dbf4d99

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/madl_esurv.mad

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ local fnil, bind3rd in MAD.gfunc
3636
local errorf in MAD.utility
3737
local minlen, minang in MAD.constant
3838
local is_implicit in element.drift
39-
local arc2cord in MAD.gmath
39+
local arc2cord, arc2len in MAD.gmath
4040

4141
local abs, sin in math
4242

@@ -177,7 +177,7 @@ local function track_thick (elm, m, fng_)
177177
local ds in m
178178
local angle in elm
179179
local no_ang = abs(angle) < minang or fng_
180-
m.el, m.ang = ds, angle*m.tdir
180+
m.el, m.ang = fng_ and m.el or ds, angle*m.tdir
181181

182182
local inter, track, thick
183183
if abs(ds) >= minlen then -- trick: driftonly+thick <=> thinonly+thin
@@ -197,8 +197,8 @@ local function fng_e1 (e, m, s)
197197
local d = s*sdir
198198
if d == -1 then
199199
local e_ = {name=e.name, dx=elc*sin((e2-e1)/2), dy=0, ds=0}
200-
yrotation(e2, m, -1) -- translation independant of direction
201-
translate(e_, m, -1)
200+
translate(e_, m, -1) -- translation independant of direction
201+
yrotation(e2, m, -1)
202202
elseif e1 ~= 0 then
203203
yrotation(e1, m, -1)
204204
end
@@ -209,8 +209,8 @@ local function fng_e2 (e, m, s)
209209
local d = s*sdir
210210
if d == 1 then
211211
local e_ = {name=e.name, dx=elc*sin((e2-e1)/2), dy=0, ds=0}
212-
translate(e_, m, -1) -- translation independant of direction
213212
yrotation(e1, m, -1)
213+
translate(e_, m, -1) -- translation independant of direction
214214
elseif e2 ~= 0 then
215215
yrotation(e2 , m, -1)
216216
end
@@ -221,19 +221,21 @@ local fng_e = \e, m, s -> yrotation(e, m, -0.5)
221221
local function track_rbend (elm, m)
222222
local fng = nil -- default: curved rbend aka sbend with parallel pole faces
223223

224-
if elm.true_rbend then -- true rbend
225-
local e1, e2, angle, l in elm
226-
if e1 and e2 then -- MAD-like Wedge rbend
224+
if elm.true_rbend then
225+
local e1, e2, angle in elm
226+
m.elc = arc2cord(m.ds, angle)
227+
if e1 and e2 then -- MAD-like wedge rbend
227228
fng = fng_e
229+
m.el = m.elc
228230
else -- true parallel rbend
229-
m.elc = arc2cord(l, angle)
230231
if e1 then
231232
m.e1, m.e2 = e1, angle - e1
232233
fng = fng_e1
233234
else
234235
m.e1, m.e2 = angle - e2, e2
235236
fng = fng_e2
236237
end
238+
m.el = arc2len(m.ds, angle)
237239
end
238240
end
239241

0 commit comments

Comments
 (0)