I’d like to ask you one more.
To make an animation, almost same graphics are drawn repeatedly.
The base figure(two circles, line, boundingbox) is fixed and only points are moved.
But it draws the base figure every time and it is not inefficient.
Is there a way to draw the base figure once, and draw the points only at each frame?
Thank you.
\startuseMPgraphic{inversionPoint}{n}
vardef findPointD(expr C, Q, r) =
numeric dist, ang;
pair X, Y;
dist := r**2/sqrt((xpart Q - xpart C)**2 + (ypart Q - ypart C)**2);
ang := angle(Q - C);
Y := C + dir(ang)*dist;
Y
enddef;
numeric radius, now, move;
pair A,B,C,P,Q;
path p,q;
radius := 2cm;
C := origin;
p := fullcircle scaled (2*radius);
z[1] = point 6 of p;
z[2] = point .8 of p;
q := (1.5*z1 - .5*z2) -- (-.5z1 + 1.5*z2);
%q := fullcircle scaled radius shifted (2cm, 1cm);
draw p;
draw q;
% end of base figure
% draw points
move := 0.1;
now := move*\MPvar{n};
P := point now along q;
Q := findPointD(C, P, radius);
drawdot P;
drawdot Q withcolor .625red;
dotlabel.lft(textext("P"),P);
dotlabel.rt(textext("Q"),Q) withcolor .625red;
\stopuseMPgraphic