Skip to content

Commit 4abd4ff

Browse files
authored
Merge pull request #302 from jgray-19/plot_improvements
Improve plotting of rbends
2 parents c625556 + 58be202 commit 4abd4ff

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/madl_plot.mad

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,14 +516,25 @@ local function layout_process_in (param, pseq)
516516
local shift
517517
for i, line in srv:iter() do
518518
local ext_line = srv[max(1, i-1)]
519+
local elm = seq[line.eidx]
519520
shift = vector{ext_line.x, ext_line.y, ext_line.z}
520-
local elm_rot = (line.kind=="sbend" or
521-
line.kind=="rbend" and seq[line.eidx].true_rbend == false)
522-
and matrix(3):roty(-line.angle/2)
523-
or 1
524-
local rot = ext_line.__map * elm_rot
521+
local rot = ext_line.__map
522+
local translation = vector(3)
523+
if elm then
524+
local kind, e1, e2 in elm
525+
if kind=="rbend" and not (e1 and e2) then
526+
if e1 then
527+
rot:mul(matrix(3):roty(-e1), rot)
528+
else
529+
rot:mul(matrix(3):roty(e2 - elm.angle), rot)
530+
translation[1] = -arc2cord(elm.l, elm.angle)*sin((e2-elm.angle/2))
531+
end
532+
elseif kind=="sbend" or kind=="rbend" then
533+
rot:mul(matrix(3):roty(-line.angle/2), rot)
534+
end
535+
end
525536

526-
data[i] = {rot, shift} -- Save the rotation and shift
537+
data[i] = {rot, shift + translation} -- Save the rotation and shift
527538
shift = layproj * shift -- Rotate the shift to x-y plane for the bline
528539
pseq.xmin, pseq.xmax = min(pseq.xmin, shift[1]), max(pseq.xmax, shift[1])
529540
pseq.ymin, pseq.ymax = min(pseq.ymin, shift[2]), max(pseq.ymax, shift[2])

0 commit comments

Comments
 (0)