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

4 vues (au cours des 30 derniers jours)
Sierra
Sierra le 30 Mai 2022
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 commentaire
Jan
Jan le 30 Mai 2022
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.

Connectez-vous pour commenter.

Réponses (1)

VINAYAK LUHA
VINAYAK LUHA le 7 Sep 2023
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.

Community Treasure Hunt

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

Start Hunting!

Translated by