Question: build a square with 2 known opposites tops

car_2som_opp := proc (U::list, V::list)  #construction d'un carré connaissant 2 sommets opposés 
local dist, eqCerU, eqCerV, r, sol, X, Y; 
dist := proc (M, N) sqrt(add((M[i]-N[i])^2, i = 1 .. 2)) end proc;
r := dist(U, V)/sqrt(2); 
eqCerU := (x-U[1])^2+(y-U[2])^2 = r^2; 
eqCerV := (x-V[1])^2+(y-V[2])^2 = r^2;
sol := solve([eqCerU, eqCerV], [x, y],allsolutions,explicit);  
map(allvalues,sol): 
X := [subs(op(sol[1]), x), subs(op(sol[1]), y)]; 
Y := [subs(op(sol[2]), x), subs(op(sol[2]), y)]; 
display(plot([U, X, V, Y, U],scaling = constrained, axes = none)) 
end proc:

car_2som_opp([-5,6],[7,-3]);"error
 

Please Wait...