import geometry;
import animation;
size(10cm);
line e = line( 45, origin),
f = line(-45, origin);
pen sidestyle = 2+defaultpen,
diagonalstyle = longdashed,
squarestyle = dotted,
altitudestyle = red+longdashed,
positivestyle = palered,
negativestyle = paleblue;
draw(e, diagonalstyle);
draw(f, diagonalstyle);
real alt = 10,
semialt = alt / 2;
draw(box((-alt, -alt), (alt, alt)), invisible);
animation movingtrapezoid = animation("movingtrapezoid");
animation withsquare = animation("withsquare");
animation hints = animation("hints");
void now(real y)
{ real yUp = y + semialt,
yDown = y - semialt;
point A = ( yDown, yDown),
B = (-yDown, yDown),
C = ( yUp, yUp),
D = (-yUp, yUp);
point A0 = (-semialt, yDown),
B0 = ( semialt, yDown),
C0 = ( semialt, yUp),
D0 = (-semialt, yUp);
/*
segment a = segment(A, B),
b = segment(B, C),
c = segment(C, D),
d = segment(D, A);
*/
path a = A--B,
b = B--C,
c = C--D,
d = D--A;
point FootUp = (0, yUp),
FootDown = (0, yDown);
segment salt = segment(FootDown, FootUp);
point K1 = (-semialt, y),
K2 = ( semialt, y);
path sq = A0--B0--C0--D0--cycle;
dot("$A$", A, SW);
dot("$B$", B, SE);
dot("$C$", C, NE);
dot("$D$", D, NW);
draw(Label("$a$", MidPoint, RightSide), a, sidestyle);
draw(Label("$b$", MidPoint, RightSide), b, sidestyle);
draw(Label("$c$", MidPoint, RightSide), c, sidestyle);
draw(Label("$d$", MidPoint, RightSide), d, sidestyle);
draw(Label("10", MidPoint, RightSide), salt, altitudestyle, Arrows);
movingtrapezoid.add();
draw(sq, squarestyle);
withsquare.add();
fill(A--A0--K1--cycle, positivestyle);
fill(B--B0--K2--cycle, positivestyle);
fill(C--C0--K2--cycle, negativestyle);
fill(D--D0--K1--cycle, negativestyle);
hints.add();
}
real epsilon = 0.1;
for (real y = -semialt + 9epsilon; y < semialt - 9epsilon; y+= epsilon)
{ save();
now(y);
restore();
}
movingtrapezoid.movie();
hints.movie();
withsquare.movie();