How can I translate a line() in the direction perpendicular to it? (Like a scan)

4 views (last 30 days)
I have a L = line([x1, x2],[y1,y2]) that I have rotated using rotate(L, [0, 0, 1], 45). So it is a line in the center of my image that is now rotated 45 degrees about he center. I want to scan this line in the direction perpendicular to it. There doesn't seem to be a translation option for lines, so looking for a method to do this if you could help.

Answers (1)

KSSV
KSSV on 8 Feb 2020
You can translate a line or given points by simply adding the value (a number) by what distance you want to translate. If you want to translate along x axes add value to x, if you want to translate along y add value to y.
Demo Code:
x = rand(1,2) ;
y = rand(1,2) ;
plot(x,y,'r') ;
hold on
% translate line by 0.3 along x-axes
xnew = x+0.3 ;
ynew = y ;
plot(xnew,ynew,'b')

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!