@@ -36,7 +36,7 @@ local fnil, bind3rd in MAD.gfunc
36
36
local errorf in MAD.utility
37
37
local minlen, minang in MAD.constant
38
38
local is_implicit in element.drift
39
- local arc2cord in MAD.gmath
39
+ local arc2cord, arc2len in MAD.gmath
40
40
41
41
local abs, sin in math
42
42
@@ -177,7 +177,7 @@ local function track_thick (elm, m, fng_)
177
177
local ds in m
178
178
local angle in elm
179
179
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
181
181
182
182
local inter, track, thick
183
183
if abs(ds) >= minlen then -- trick: driftonly+thick <=> thinonly+thin
@@ -197,8 +197,8 @@ local function fng_e1 (e, m, s)
197
197
local d = s*sdir
198
198
if d == -1 then
199
199
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)
202
202
elseif e1 ~= 0 then
203
203
yrotation(e1, m, -1)
204
204
end
@@ -209,8 +209,8 @@ local function fng_e2 (e, m, s)
209
209
local d = s*sdir
210
210
if d == 1 then
211
211
local e_ = {name=e.name, dx=elc*sin((e2-e1)/2), dy=0, ds=0}
212
- translate(e_, m, -1) -- translation independant of direction
213
212
yrotation(e1, m, -1)
213
+ translate(e_, m, -1) -- translation independant of direction
214
214
elseif e2 ~= 0 then
215
215
yrotation(e2 , m, -1)
216
216
end
@@ -221,19 +221,21 @@ local fng_e = \e, m, s -> yrotation(e, m, -0.5)
221
221
local function track_rbend (elm, m)
222
222
local fng = nil -- default: curved rbend aka sbend with parallel pole faces
223
223
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
227
228
fng = fng_e
229
+ m.el = m.elc
228
230
else -- true parallel rbend
229
- m.elc = arc2cord(l, angle)
230
231
if e1 then
231
232
m.e1, m.e2 = e1, angle - e1
232
233
fng = fng_e1
233
234
else
234
235
m.e1, m.e2 = angle - e2, e2
235
236
fng = fng_e2
236
237
end
238
+ m.el = arc2len(m.ds, angle)
237
239
end
238
240
end
239
241
0 commit comments