How to find the 'y' values of line which is perpendicular to another line?

조회 수: 4 (최근 30일)
Sierra
Sierra 2022년 5월 30일
답변: VINAYAK LUHA 2023년 9월 7일
I have (x, y) data of the blue line, and the only the x data of the red points.
I want draw a line which is perpendicular to the blue line so that I can make a patch like image.
But I don't know how to get the two 'y' values of the pair of red points.
Let me know whether there is a formula or a function of MATLAB.
Thanks.
  댓글 수: 1
Jan
Jan 2022년 5월 30일
What do you eactly have? The line consists of an infinite number of points. So I do not think, that you have the data of the line, but maybe the coordinates or the blue dots on this line. Now it would be useful, if you post, in which format these coordinates are stored.
If the blue line has the the normalized direction vector [nx, ny], the lines orthogonal to it have the directions [ny, -nx] and [-ny, nx]. "Perpendicular" means, that the dot product is zero.

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

답변 (1개)

VINAYAK LUHA
VINAYAK LUHA 2023년 9월 7일
Hi Sierra,
Given-
Coordinates of four points on blue line.
x coordinates of a pair of red points on either side of blue line
Assuming, the known point on blue line forms the perpendicular intersection point between a red and blue line,
Here’s how to calculate the y coordinates of involved red points.
  1. Find the equation of the blue line using the blue points, let it be y=mx+c.
  2. Let the red points be (x1,y1) and (x2,y2) and the known perpendicular intersection point be (xb,yb).
  3. Now the slope of red line is (-1/m) [product of slope of two perpendicular lines is -1].
  4. This leads to following three equations and three unknowns.
y1=(-1/m)x1+c2
yb=(-1/m)xb+c2
y2=(-1/m)x2=c2
Solve the above linear equations for y1 and y2.
Repeat the same process for all red lines and plot the patch using the “plot” function
Hope this helps.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by