|
Hi everyone. I'm trying to plot a line perpendicular and in the middle of another line. I'm already half way through but I'm stuck when trying to plot from the middle:
check this link:
http://dl.dropbox.com/u/5800838/untitled.jpg
I did the following code:
x1 =GR_endpoints(plotnext,2) %start point of line
y1 =GR_endpoints(plotnext,1)
x2 =GR_endpoints(plotnext+1,2) %end point of line
y2 =GR_endpoints(plotnext+1,1)
P1 = [x1 y1]
P2 = [x2 y2]
d = 75
t = sqrt((x2-x1)^2+(y2-y1)^2);
x3 = x1-(y2-y1)/t*d
y3 = y1+(x2-x1)/t*d
line([x3 x1], [y3 y1] , 'Color','b', 'LineStyle','-', 'LineWidth', 0.5)
N.B. I did not use gradient since I saw one example in this forum but this can lead to a division by 0. Please help
Regards
Kenneth
|