Question: Why this "Error, invalid input: subs received 1, which is not valid for its 1st argument"

I would like to show : in a quadrilateral circumscribed to an ellipse, the line passing through the middle of the diagonals passes through the centre of the ellipse.
My code is :

restart; with(geometry): with(plots): `local`(O):
_EnvHorizontalName := x: _EnvVerticalName := y:

alias(coor = coordinates):
ell := x^2/a^2+y^2/b^2 = 1:
point(P1,a*cos(omega), b*sin(omega)):
point(P2,a*cos(omega-(1/2)*Pi), b*sin(omega-(1/2)*Pi)): 
point(P3,a*cos(omega+(8/7)*Pi), b*sin(omega+(8/7)*Pi)):
point(P4,a*cos(omega+5*Pi*(1/2)), b*sin(omega+5*Pi*(1/2))):
a := 5: b := 3: omega := (1/5)*Pi:
Ell := implicitplot(ell, x = -a .. a, y = -b .. b, color = red): 
dr := draw([seq(P || k, k = 1 .. 4)], axes = normal, printtext = true):

for i from 1 to 4 do tgP||i := x*coor(P||i)[1]/a^2+y*coor(P||i)[2]/b^2 = 1 od:
poly := Matrix([coor(P1), coor(P2), coor(P3), coor(P4)]):
Quadri := polygonplot(poly, axes = normal, color = "DarkGreen", transparency = .8):

with(combinat): with(ListTools):
L := [1, 2, 3, 4]:
for i from 1 to 4 do Rotate(L, i)[1] od:
for i to 4 do solve({(tgP || Rotate)(L, i)[1], tgP || i}, {x, y}); point(S || i, subs(%, x), subs(%, y)); coor(S || i) end do;
Error, invalid input: subs received 1, which is not valid for its 1st argument
#otherwise
solve({tgP1, tgP2}, {x, y}): point(S1, subs(%, x), subs(%, y)); coor(S1):
                               S1
solve({tgP2, tgP3}, {x, y}): point(S2, subs(%, x), subs(%, y)); coor(S2):
                               S2
solve({tgP3, tgP4}, {x, y}): point(S3, subs(%, x), subs(%, y)); coor(S3):
                               S3
solve({tgP1, tgP4}, {x, y}): point(S4, subs(%, x), subs(%, y)); coor(S4):
                               S4

poly := Matrix([coor(S1), coor(S2), coor(S3), coor(S4)]):
Quadri2 := polygonplot(poly, axes = normal, color = "DarkGreen", transparency = .9):
#dr2:=draw(seq(S||k,k =1..4), axes = normal, printtext = true):
line(diag13, [S1, S3]): line(diag24, [S2, S4]): midpoint(M1, S1, S3): midpoint(M2, S4, S2): 
line(Lm, [M1, M2]):
dr2 := draw([S1, S2, S3, S4, M1, M2, Lm(color = black), diag13, diag24], axes = normal, printtext = true):
for i from 1 to 4 do
TgP||i := implicitplot(tgP||i, x = -a-5 .. a+5, y = -b-5 .. b+5, color = blue) od:
display([Ell, seq(TgP||i,i=1..4), Quadri, Quadri2,dr,dr2], view = [-a-5 .. a+3, -b-2 .. b+2], 
scaling = constrained, size = [700, 700]); Thank you for your answere.

Please Wait...