> 
projcross:=overload([
proc(A::Matrix(1,3),B::Matrix(1,3))
option overload;
description "join of points";
local a:=convert(A,Vector[row]),b:=convert(B,Vector[row]);
uses LinearAlgebra;
print("line thro' points");
convert((a &x b)^%T,Matrix);
end proc,
proc(A::Matrix(3,1),B::Matrix(3,1))
option overload;
description "meet of lines";
local a:=convert(A,Vector[column]),b:=convert(B,Vector[column]);
uses LinearAlgebra;
print("intersect point");
convert((a &x b)^%T,Matrix);
end proc,
proc(A::{Matrix(1,3),Matrix(3,1)},B::{Matrix(1,3),Matrix(3,1)})
option overload;
description "incidence of point and line";
uses LinearAlgebra;
local a,b;
if type(A,'Matrix'(1,3))and type(B,'Matrix'(3,1)) or type(A,'Matrix'(3,1))and type(B,'Matrix'(1,3)) then #not working
a:=convert(A,Vector[row]);
b:=convert(B,Vector[row]);
end if;
print("if = 0 coincident");
a.b ;
end proc
]):

> 
projcross(<<124>>,<<357>>)


(1) 
> 
projcross(<<1,2,4>>,<<3,5,7>>)


(2) 
> 
projcross(<<124>>,<<34,5,11>>)


(3) 
> 
projcross(<<34,5,11>> ,<<357>> )


(4) 
> 
#This section is to derive a CrossProduct and DotProduct for row and column matrix inputs

> 
M:=<A[1,1]A[1,2]A[1,3]> ; #point


(5) 
> 
N:=<B[1,1]B[1,2]B[1,3]> ; #point


(6) 
> 
(M &x N)^%T ; #line thro' points


(7) 
> 
R:=<A[1,1],A[2,1],A[3,1]> ;# line


(8) 
> 
S:=<B[1,1],B[2,1],B[3,1]> ;# line


(9) 
> 
(R &x S)^%T ;# intersect point


(10) 
> 
T:=<A[1,1]A[1,2]A[1,3]> ;#point


(11) 
> 
U:=<B[1,1],B[2,1],B[3,1]> ;# line


(12) 
> 
DotProduct(T,U,conjugate=false) ; #check coincidence of point and line


(13) 
> 
V:=<A[1,1],A[2,1],A[3,1]> ;# line


(14) 
> 
W:=<B[1,1]B[1,2]B[1,3]> ;#point


(15) 
> 
DotProduct(V,W,conjugate=false) ; #check coincidence of line and point


(16) 
> 
# CrossProduct and DotProduct procedure for matrix inputs

> 
ProjCp:=overload([
proc(a::Matrix(1,3),b::Matrix(1,3))
option overload;
description "join of points";
local A:=a,B:=b;
print("line thro' points");
<<A[1, 2]*B[1, 3]  A[1, 3]*B[1, 2],A[1, 1]*B[1, 3] + A[1, 3]*B[1, 1],A[1, 1]*B[1, 2]  A[1, 2]*B[1, 1]>>;
end proc,

> 
proc(a::Matrix(3,1),b::Matrix(3,1))
option overload;
description "meet of lines";
local A:=a,B:=b;
print("intersect point");
<<A[2, 1]*B[3, 1]  A[3, 1]*B[2, 1]  A[1, 1]*B[3, 1] + A[3, 1]*B[1, 1]  A[1, 1]*B[2, 1]  A[2, 1]*B[1, 1] >>;
end proc,
proc(A::{Matrix(1,3),Matrix(3,1)},B::{Matrix(1,3),Matrix(3,1)})
option overload;
description "incidence of point and line";
local dp;
uses LinearAlgebra;
if type(A,'Matrix'(1,3))and type(B,'Matrix'(3,1)) then
dp:=A[1, 1]*B[1, 1] + A[1, 2]*B[2, 1] + A[1, 3]*B[3, 1];
elif type(A,'Matrix'(3,1))and type(B,'Matrix'(1,3)) then
dp:=A[1, 1]*B[1, 1] + A[2, 1]*B[1, 2] + A[3, 1]*B[1, 3];
end if;
print("if = 0 coincident");
return dp
end proc,
proc(A::{Matrix(1,3),list})
option overload;
description "convert to/from cartesian";
if type(A,'Matrix'(1,3)) and A[1,3]<>0 then
[A[1,1]/A[1,3],A[1,2]/A[1,3]];
elif A::list then
<<A[1]A[2]1>>;
end if;
end proc,
proc(A::{Matrix(3,1)},{vars:=[x,y]})
option overload;
description "convert to expression";
A[1,1]*vars[1]+A[2,1]*vars[2]+A[3,1];
end proc

> 
p1:=<<124>>:p2:=<<357>>:p3:=a*p1b*p2:

> 
L1:=<<5,7,8>>:L2:=<<1,4,6>>:


(17) 

(18) 

(19) 

(20) 
> 
ProjCp(ProjCp(p1,p2),p3)


(21) 
> 
Cartlist:=ProjCp~([p1,p2,p3])


(22) 

(23) 

(24) 
