is there easy way to simulate lines rotation like robotic arm following point P moving by adjusting angle q1 and q2?

i feel point two lines and simulate static two lines in animate is also not easy.

with(plots):

with(geometry):

#Joint at (5,5)

#length a 2, y=7, x, solve(subs(y=7,2^2 = (y-5)^2+(x-5)^2), x)[1];

#length b 2, y=1, x, solve(subs(y=4,2^2 = (y-5)^2+(x-5)^2), x)[1];

point(A, 5, 5), point(B, solve(subs(y=7,2^2 = (y-5)^2+(x-5)^2), x)[1], 7):

point(C, 5, 5), point(D, solve(subs(y=4,2^2 = (y-5)^2+(x-5)^2), x)[1], 4):

line(L1, [A, B]);

line(L2, [C, D]);

_EnvHorizontalName := x;

_EnvVerticalName := y;

Equation(L1);

Equation(L2);

solve(Equation(L1), y);

solve(Equation(L2), y);

plot([solve(Equation(L1), y),solve(Equation(L2), y)], x = 1 .. 2);

animate(plot, [Equation(L1),Equation(L2), x = 0 .. 2], A = -3 .. 3);

Angle Reference from below

angle of L2 , q1a

angle of L1, q2a

p1 := vector([a*cos(q1), a*sin(q1)]);

P := evalm(p1 + b*vector([cos(q1+q2), sin(q1+q2)]));

Pe := map(expand, P);

A := {cos(q1) = c1, sin(q1) =s1, cos(q2)=c2, sin(q2)=s2};

P := subs(A, op(Pe));

F1 := [x - P[1], y - P[2], s1^2+c1^2-1, s2^2+c2^2-1 ];

F2 := subs({a=1, b=1}, F1);

with(Groebner):

g1 := Basis(F2, plex(c2, s2, c1, s1, y, x));

g1 := [-4*x^2+x^4+2*x^2*y^2+y^4-4*y*x^2*s1-4*y^3*s1+4*s1^2*x^2+4*s1^2*y^2, 2*y*s1+2*x*c1-x^2-y^2, 4*x-x^3-y^2*x+2*y*x*s1-2*y^2*c1-4*s1^2*x+4*y*s1*c1, s1^2+c1^2-1, x*s1-y*c1+s2, -y^2+2-x^2+2*c2];

map(indets, g1);

g2 := Basis(F2, plex(c2, s2, c1, s1));

assume point x = 1, y = 0.5

g2spec := subs({x=1, y=1/2}, [g2[1],g2[3]]);

S1 := [solve(g2spec[1])];

q1a := evalf(arcsin(S1[1]));

q1b := evalf(arcsin(S1[2]));

S2 := [solve(subs(s1=S1[1], g2spec[2])), solve(subs(s1=S1[2], g2spec[2])) ];

q2a := evalf(arcsin(S2[1]));

q2b := evalf(arcsin(S2[2]));

q2a := subs({a=2,b=2}, q2a);

if q2a < 0 then

q2a_pi := evalf(eval(-q2a-Pi));

else

q2a_pi := evalf(eval(Pi-q2a));

end if:

q2a_pi;

q2b := subs({a=2,b=2}, q2b);

if q2b < 0 then

q2b_pi := evalf(eval(-q2b-Pi));

else

q2b_pi := evalf(eval(Pi-q2b));

end if:

q2b_pi;