Would you tel me why this code doesn't work : the lenghts of BC and BD are not constant. Thank you very much.

restart;

with(plots);

with(plottools);

AB := 39;

BC := 140;

BD := 140;

local(D);

Vdot := proc(U, V) local i; add(U[i]*V[i], i = 1 .. 2); end proc;

dist := proc(M, N) sqrt(Vdot(expand(M - N), expand(M - N))); end proc;

Fig := proc(alpha)

local cir, R, BC, BD, AC, AD, lAC, A, lBC, lAB, lBD, beta, B, C, Cc, Dd, D, Aa, Bb, F1, F2, d, k, h, i, Pb, Ph, pb1, ph1, Qb, Qh, qh1, qb1, p1, P1, p2, P2, p3, P3, p4, P4, q1, Q1, q2, Q2, q3, Q3, q4, Q4, cy1, cy2, cy3, cy4, tA, tB, tC, tD;

A := [0, 0]; R := 39; d := 83; BC := 140; BD := 140;

B := [R*cos(alpha), R*sin(alpha)];

k := BC/R; h := 1/2*sqrt(2);

Ph := [h*(R + BC), h*(R + BC)];

Pb := [h*(-R + BC), h*(-R + BC)];

Qh := [-h*(R + BC), h*(R + BC)];

Qb := [-h*(-R + BC), h*(-R + BC)];

P1 := [Ph[1] - 1/2*d*h, Ph[2] + 1/2*d*h];

P2 := [Ph[1] + 1/2*d*h, Ph[2] - 1/2*d*h];

P3 := [Pb[1] - 1/2*d*h, Pb[2] + 1/2*d*h];

P4 := [Pb[1] + 1/2*d*h, Pb[2] - 1/2*d*h];

Q1 := [Qh[1] + 1/2*d*h, Qh[2] + 1/2*d*h];

Q2 := [Qh[1] - 1/2*d*h, Qh[2] - 1/2*d*h];

Q3 := [Qb[1] + 1/2*d*h, Qb[2] + 1/2*d*h];

Q4 := [Qb[1] - 1/2*d*h, Qb[2] - 1/2*d*h];

cir := circle(A, R, color = black, linestyle = longdash);

F1 := plot(x, x = -R .. R + BC, color = black, linestyle = longdash);

F2 := plot(-x, x = -R - BC .. R, color = black, linestyle = longdash);

AC := R*(cos(alpha) + sqrt(k^2 - sin(alpha)^2));

C := [h . AC, h . AC];

AD := R*(cos(Pi - alpha) + sqrt(k^2 - sin(Pi - alpha)^2));

D := [-h*AD, h*AD]; lBC := plot([B, C], color = red, thickness = 4);

lAB := plot([A, B], color = red, thickness = 4); print(evalf(dist(B, C)), evalf(dist(B, D)));

lBD := plot([B, D], color = red, thickness = 4);

pb1 := pointplot(Pb, symbol = solidcircle, symbolsize = 5, color = black);

ph1 := pointplot(Ph, symbol = solidcircle, symbolsize = 5, color = black);

qb1 := pointplot(Qb, symbol = solidcircle, symbolsize = 5, color = black);

qh1 := pointplot(Qh, symbol = solidcircle, symbolsize = 5, color = black);

p1 := pointplot(P1, symbol = solidcircle, symbolsize = 10, color = black);

p2 := pointplot(P2, symbol = solidcircle, symbolsize = 10, color = black);

p3 := pointplot(P3, symbol = solidcircle, symbolsize = 10, color = black);

p4 := pointplot(P4, symbol = solidcircle, symbolsize = 10, color = black);

q1 := pointplot(Q1, symbol = solidcircle, symbolsize = 10, color = black);

q2 := pointplot(Q2, symbol = solidcircle, symbolsize = 10, color = black);

q3 := pointplot(Q3, symbol = solidcircle, symbolsize = 10, color = black);

q4 := pointplot(Q4, symbol = solidcircle, symbolsize = 10, color = black);

Aa := pointplot(A, symbol = solidcircle, symbolsize = 12, color = blue);

Bb := pointplot(B, symbol = solidcircle, symbolsize = 12, color = blue);

Cc := pointplot(C, symbol = solidcircle, symbolsize = 12, color = blue);

Dd := pointplot(D, symbol = solidcircle, symbolsize = 12, color = blue);

cy1 := plot([P1, P3], color = black, thickness = 8); cy2 := plot([P2, P4], color = black, thickness = 8);

cy3 := plot([Q1, Q3], color = black, thickness = 8); cy4 := plot([Q2, Q4], color = black, thickness = 8);

tA := textplot([0, 0, "A"], 'align' = {'above', 'right'});

tB := textplot([B[1], B[2], "B"], 'align' = {'above', 'right'});

tC := textplot([C[1], C[2], "C"], 'align' = {'above', 'right'});

tD := textplot([D[1], D[2], "D"], 'align' = {'above', 'right'});

display([cir, F1, F2, pb1, ph1, qb1, qh1, p1, p2, p3, p4, q1, q2, q3, q4, Aa, Bb, Cc, Dd, lAB, lBC, lBD, cy1, cy2, cy3, cy4, tA, tB, tC, tD], scaling = constrained); end proc;

Fig(Pi/3);

display([seq(Fig((2*alpha*Pi)/50), alpha = 0 .. 50)], insequence = true, axes = none);