I have two points A and B, I call the line consisting of A and B as LAB:ax+by+c=0, I would like to draw a line segment starting from the point B perpendicular to LAB and with length len such that the line segment stays on positive side of the line LAB, which is the semi-space ax+by+c>0. How is it possible in Tikz?
I managed to calculate and draw such line in Matlab, here is the code. It might be helpful to understand what I mean:
%% input data A.x = 2; A.y = 2; B.x = 6; B.y = 5; d = 2.5; % the length len P = B; % selected end point %% calculation v.x = B.x - A.x; v.y = B.y - A.y; X = v.y*d/sqrt(1+v.x^2); Y = -v.x/v.y*X; % in one side of the line LAB C.x = X + P.x; C.y = Y + P.y; % in another side of the line LAB D.x = P.x - X; D.y = P.y - Y; %% visualization figure(1);hold on; axis equal; plot(A.x,A.y,'ro',B.x,B.y,'bo',C.x,C.y,'go',D.x,D.y,'yo'); plot([A.x B.x],[A.y B.y],'-k'); plot([B.x C.x],[B.y C.y],'-k'); plot([B.x D.x],[B.y D.y],'-k');