Finding the point on a line equidistant to two 3-D points
by: Yufang Hao
Purpose: Find a point in a straight line , with the same distance of the points A(1,2,3) and B(3,0,1).
>
General Approach to the Question, solving manually
> restart;
let P(x,y,z) be a point on the line that has equal distance from both A and B, thus x=2+t, y=t, z=-3+2*t for some t and AP=BP, then
> x := t->2+t; y := t->t; z := t->-3+2*t;
> A := [1,2,3]; B := [3,0,1];
> AP := sqrt( (x(t)-A[1])^2 + (y(t)-A[2])^2 + (z(t)-A[3])^2 ); BP := sqrt( (x(t)-B[1])^2 + (y(t)-B[2])^2 + (z(t)-B[3])^2 );
> eqn := AP=BP;
Solve the equation using Maple's solve() command.
> t_sol := solve(eqn,t);
substituting t back to will give you the wanted P
> P := [x(t_sol),y(t_sol),z(t_sol)];
Plotting the points and lines in 3D using pointplot3d() and plot3d() commands. Please refers to HELP.
> with(plots):
Warning, the name changecoords has been redefined
> points_AB := pointplot3d({A,B}, color=red, symbolsize=20, symbol=circle):
> point_P := pointplot3d({P}, color=blue, symbolsize=30, symbol=cross):
> t1:=-10: t2:=10: line_end1:=[x(t1),y(t1),z(t1)]: line_end2:=[x(t2),y(t2),z(t2)]: line_t := pointplot3d({line_end1,line_end2}, connect=true, color=red, thickness=2 ):
> line_AP := pointplot3d({A,P}, connect=true, color=green, thickness=3):
> line_BP := pointplot3d({B,P}, connect=true, color=green, thickness=3):
> display3d({point_P,points_AB,line_AP,line_BP,line_t}, axes=normal, labels=['x','y','z'], orientation=[-60,60]);
> line_t_option := plot3d([x(t),y(t),z(t)], t=-10..10, s=-10..10, thickness=3):
> display3d({point_P,points_AB,line_AP,line_BP,line_t_option}, axes=normal, labels=['x','y','z'], orientation=[-60,60]);