Question: poncelet theorem for the triangle

restart;
with(geometry);
with(plots);
_EnvHorizontalName = 'x';
_EnvVerticalName = 'y';
Vdot := proc(U, V) local i; add(U[i]*V[i], i = 1 .. 2); end proc;
dist := proc(M, N) sqrt(Vdot(M - N, M - N)); end proc;
EQ := proc(M, N) local eq, a, b, c; eq := simplify(expand((y - M[2])/(x - M[1]) - (N[2] - M[2])/(N[1] - M[1]))*(x - P1[1])*(P2[1] - P1[1])); a := coeff(eq, x); b := coeff(eq, y); c := tcoeff(eq, [x, y]); RETURN(-a*x/c - b*y/c - 1); end proc;
R := 5;
ang := [2/3*Pi, -3*Pi*1/4, -Pi*1/6];
seq(point(`||`(P, i), [R*cos(ang[i]), R*sin(ang[i])]), i = 1 .. 3);
seq(dsegment(`||`(seg, i), [`||`(P, i), `||`(P, irem(i, 3) + 1)]), i = 1 .. 3);
circle(cir, [point(OO, [0, 0]), R]);
sol := solve(subs(x = 2, Equation(cir, [x, y])), y);
point(A, [2, sol[1]]);
triangle(Tri, [P1, P2, P3]);
incircle(inc, Tri, 'centername' = oo);
circle(Cr, [A, oo]);
sol := solve({Equation(Cr, [x, y]), Equation(inc, [x, y])}, {x, y});
point(H1, [subs(sol, x), subs(sol, y)]);
line(L, [A, oo]);
reflection(H2, H1, L);
line(L1, [A, H1]);
line(L2, [A, H2]);
Equation(cir, [x, y]);
Equation(L1, [x, y]);
sol := solve({Equation(L1, [x, y]), Equation(cir, [x, y])}, {x, y});
evalf(%);
point(M1, [subs(sol, x), subs(sol, y)]);
sol2 := solve({Equation(L2, [x, y]), Equation(cir, [x, y])}, {x, y});
evalf(%);
point(M2, [subs(sol2, x), subs(sol2, y)]);
triangle(TR, [M1, M2, A]);
display([draw([P1(symbol = solidcircle, symbolsize = 8, color = blue), P2(symbol = solidcircle, symbolsize = 8, color = blue), P3(symbol = solidcircle, symbolsize = 8, color = blue), A(symbol = solidcircle, symbolsize = 8, color = black), H1(symbol = solidcircle, symbolsize = 8, color = black), H2(symbol = solidcircle, symbolsize = 8, color = black), L1(color = black), L2(color = black), seg1(color = magenta), seg2(color = magenta), seg3(color = magenta), Cr(color = black), cir(color = magenta), inc(color = blue)]), textplot([seq([coordinates(`||`(P, i))[], convert(`||`(P, i), string)], i = 1 .. 3)], 'align' = {'above', 'left'})], view = [-6 .. 10, -15 .. 6], scaling = constrained, size = [800, 800], axes = none);
It seems that there is conusion between M1 and M2. How to write letters A, M1 ,M2, H1, H2 ? Thank you.

Please Wait...