Question: Projection of a point on a line

do not accept substitution after line EQ
restart;
with(LinearAlgebra);
A := [1, -2];
B := [-2, 3];
C := [1, 1];
M := [x, y];
ProjPL := proc(C, A, B) local M, AB, AM, Q, eq, EQ, eq1, a, b, c, t, tt, n, dist, x, y, xH, yH, H, CH, no; M := [x, y]; AM := M - A; AB := B - A; Q := Matrix(2, [AM, AB]); eq := Determinant(Q); a := coeff(eq, x); b := coeff(eq, y); c := tcoeff(eq); dist := abs(a + b + c)/sqrt(a^2 + b^2); n := [a, b]; x := C[1] + n[1]*t; y := C[2] + n[2]*t; EQ := eq = 0; tt := solve(subs(x = C[1] + n[1]*t, y = C[2] + n[2]*t, EQ), t); xH := subs(t = tt, x); yH := subs(t = tt, y); H := [xH, yH]; CH := H - C; no := sqrt(CH[1]^2 + CH[2]^2); RETURN(EQ, dist, H, no); end proc;
ProjPL(C, A, B);
Thank you for your help.

Please Wait...