# Question:Handling lists and vectors for 3D lines. Changing the colour of plot3d lines?

## Question:Handling lists and vectors for 3D lines. Changing the colour of plot3d lines?

Maple 2023

Was experimenting with methods to handle the representation of 3D lines and plotting them. Where I normally use a point and a direction vector to dascribe the line.

With a bit of experimenting I see the element wise operation `+`~  or  `-`~  using prefix notation saves a lot of time converting vector to lists and vice a versa.  Would be interested to know if there are better techniques.

On the plotting side using plot3d Can the colour of the lines be changed individually? Or should I use a different plotting command?

 > restart
 > with(plottools):
 > l:=([2,-3,1],<3,7/9,6>);   # 3d line point + vector
 > P:=[7,-8,9]
 (1)
 > pl:=`+`~(lambda*l[2],l[1]); #3d line as vector eqn
 >
 (2)
 > vnl:=`-`~(pl,P) ; #vector from Point P to 3D line
 >
 (3)
 > vnl.l[2] assuming `real` ; #dot product of vectors= 0 when perpendicular
 >
 (4)
 > sol:=solve( { (4) }, [lambda] )[];
 (5)
 > intP:=eval(pl,sol)  #intersection point
 (6)
 > l2:=P,eval(vnl,sol) ;  #perpendicular 3D line through P
 (7)
 > pl2:=`+`~(lambda*l2[2],l2[1]); #3D line as vector eqn
 (8)
 > plots:-display(plot3d([pl,pl2],lambda=-.5..1.8,thickness=0,colour=[orange,purple],axes=normal,scaling=constrained),                 point(P,colour=blue ,symbolsize=15,symbol=solidsphere),                 point(l[1],colour=green ,symbolsize=15,symbol=solidsphere),                 point(eval(pl,sol),colour=red ,symbolsize=15,symbol=solidsphere),                 arrow(l,0.2, 0.4, 0.1,colour=green),                 arrow(l2,0.2, 0.4, 0.1,colour=blue));
 >
 >