필터 지우기
필터 지우기

How to plot a line parallel to a line with a distance of d between them ?

조회 수: 19 (최근 30일)
Priya
Priya 2014년 3월 5일
댓글: jaya prakash 2014년 12월 2일
I have a line whose slope is m and y-intercept is c.
I wan to make a parallel line above and below to this line with at a distance of d between them.
Can anyone help ?

답변 (2개)

Roger Stafford
Roger Stafford 2014년 3월 5일
My guess is that where Priya says "a parallel line above and below to this line with at a distance of d between them", the orthogonal distance between them is to be d, not the vertical distance. If so, the equations of the two lines would be:
Line above:
y = m*x + c + d*sqrt(1+m^2);
Line below:
y = m*x + c - d*sqrt(1+m^2);
  댓글 수: 2
Priya
Priya 2014년 3월 5일
Hi,
The solution was simple. Actually the slope of the line parallel to a given line, will be same as that of the given line and the intercept will actually be +/- distance d.
Thanks for efforts everyone
Roger Stafford
Roger Stafford 2014년 3월 6일
Priya, I suggest you set m equal to a very large number such as m = 100, and make a plot of your three lines (using "axis equal") to see if a vertical displacement by d rather than an orthogonal one is what you are really after. The lines will look much closer together than your d value if a vertical displacement is used.

댓글을 달려면 로그인하십시오.


Iain
Iain 2014년 3월 5일
For where you want to plot it:
x = 0:1:42;
m = 4;
c = -12;
Line 1 =
y1 = m*x + c
Line 2 (above by d)
y2 = m*x + c + d
Line 3 (below by d)
y3 = m*x + c - d
plot(x,y1,x,y2,x,y3)
  댓글 수: 2
jaya prakash
jaya prakash 2014년 12월 2일
Hi
how could you tell that
x = 0:1:42; m = 4; c = -12;
for every line?
for example if i had a set of polygon points say a=[0 0;1 0;1 1;0 1] then how i will get a offset for a square with a distance d=0.1 ?
thanks in advance for helping
jaya prakash
jaya prakash 2014년 12월 2일
Otherwise i will keep my question in a simple way
i have a line from point a(0,0) to b(1,1)
how would i get a offset line at a distance d=0.1 on both sides ?
thanks in advance

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by