pds1:=
Input
(
"Ellipse/Box width periods"
,
2,2600,40);
pds2:=
Input
(
"Ellipse/Box separation periods"
,
-26000,2600,5);
plot:=
Input
(
"plot: [1]Box, [2]Ellipse, [3]Both"
,1,3,3);
pds2:=
LastValue
(
If
(pds2<=-pds1,-pds1+1,pds2));
p2:=pds2;
p1:=pds1+p2;
start:=
Cum
(1)=
LastValue
(
Cum
(1))-p1;
end:=
Cum
(1)=
LastValue
(
Cum
(1))-p2;
restrict:=
Ref
(
Ref
(
ValueWhen
(1,start,1),-p2),p2);
Hi:=
LastValue
(
Highest
(
ValueWhen
(1,restrict,
H
)))
+restrict-1;
Lo:=
LastValue
(
Lowest
(
ValueWhen
(1,restrict,
L
)))
+restrict-1;
top:=
If
(start
OR
end,Lo,Hi);
bot:=
If
(start
OR
end,Hi,Lo);
midX:=(p1-p2)/2;
midY:=(Hi-Lo)/2;
tX:=
Cum
(1)-midX-(
LastValue
(
Cum
(1))-p1);
ellipse:=
Sqrt
(midY*midY*(1-
Min
(tX*tX/midX/midX,1)));
upperE:=Lo+midY+ellipse;
lowerE:=Hi-midY-ellipse;
If
(plot=2,upperE,Hi);
If
(plot=2,lowerE,Lo);
If
(plot=2,upperE,top);
If
(plot=2,lowerE,bot);
If
(plot=1,top,upperE);
If
(plot=1,bot,lowerE);
p2:=p1+pds2;
p1:=pds1+p2;
start:=
Cum
(1)=
LastValue
(
Cum
(1))-p1;
end:=
Cum
(1)=
LastValue
(
Cum
(1))-p2;
restrict:=
Ref
(
Ref
(
ValueWhen
(1,start,1),-p2),p2);
Hi:=
LastValue
(
Highest
(
ValueWhen
(1,restrict,
H
)))
+restrict-1;
Lo:=
LastValue
(
Lowest
(
ValueWhen
(1,restrict,
L
)))
+restrict-1;
top:=
If
(start
OR
end,Lo,Hi);
bot:=
If
(start
OR
end,Hi,Lo);
midX:=(p1-p2)/2;
midY:=(Hi-Lo)/2;
tX:=
Cum
(1)-midX-(
LastValue
(
Cum
(1))-p1);
ellipse:=
Sqrt
(midY*midY*(1-
Min
(tX*tX/midX/midX,1)));
upperE:=Lo+midY+ellipse;
lowerE:=Hi-midY-ellipse;
If
(plot=2,upperE,Hi);
If
(plot=2,lowerE,Lo);
If
(plot=2,upperE,top);
If
(plot=2,lowerE,bot);
If
(plot=1,top,upperE);
If
(plot=1,bot,lowerE);
p2:=p1+pds2;
p1:=pds1+p2;
start:=
Cum
(1)=
LastValue
(
Cum
(1))-p1;
end:=
Cum
(1)=
LastValue
(
Cum
(1))-p2;
restrict:=
Ref
(
Ref
(
ValueWhen
(1,start,1),-p2),p2);
Hi:=
LastValue
(
Highest
(
ValueWhen
(1,restrict,
H
)))
+restrict-1;
Lo:=
LastValue
(
Lowest
(
ValueWhen
(1,restrict,
L
)))
+restrict-1;
top:=
If
(start
OR
end,Lo,Hi);
bot:=
If
(start
OR
end,Hi,Lo);
midX:=(p1-p2)/2;
midY:=(Hi-Lo)/2;
tX:=
Cum
(1)-midX-(
LastValue
(
Cum
(1))-p1);
ellipse:=
Sqrt
(midY*midY*(1-
Min
(tX*tX/midX/midX,1)));
upperE:=Lo+midY+ellipse;
lowerE:=Hi-midY-ellipse;
If
(plot=2,upperE,Hi);
If
(plot=2,lowerE,Lo);
If
(plot=2,upperE,top);
If
(plot=2,lowerE,bot);
If
(plot=1,top,upperE);
If
(plot=1,bot,lowerE)