Question

my math is a bit rusty seeing as how it's been years.

I added a small example graph to make this more clear. I have 2 points in a cartesian coordinate system. On this line I take a random point, in this example the center. Now I draw the perpendicular line on that point. I want to know the coordinate of a point on that line, a certain known distance from that point. What's the formula to calculate this?

Graph: http://i44.tinypic.com/9vcjlf.png

In short Known constants:

  • the coordinates of points A, B and C.
  • the lengths t1, t2, t3

Required:

  • the coordinate of the colored points

Thanks in advance

Was it helpful?

Solution

If these are the coordinates of A, B:

A = (Ax, Ay)
B = (Bx, By)

Then the vector from A to B is given by:

vector AB = (Bx-Ax, By-Ay) = (BAx, BAy)

And the unit vector (the vector of length 1) which points in the same direction is given by:

                     (BAx, BAy)
unit vector AB = ------------------,  where length = sqrt(BAx^2 + BAy^2)
                       length

Now, the unit vector which is perpendicular to AB is given by:

                                   (-BAy, BAx)
unit vector perpendicular to AB = -------------  
                                     length

There are two possible unit vectors perpendicular to AB. The one shown above is what you'd obtain by rotating the unit vector AB counterclockwise by 90 degrees.

Given the above calculations, here are the desired coordinates:

coordinate at t1 = (Bx, By) + t1 * (unit vector perpendicular to AB)
coordinate at t2 = (Bx, By) + t2 * (unit vector perpendicular to AB)
coordinate at t3 = (Bx, By) - t3 * (unit vector perpendicular to AB)

To be explicit,

                   (Bx + t1*(-By+Ay), By + t1*(Bx-Ax))
coordinate at t1 = -------------------------------------
                       sqrt((Bx-Ax)^2 + (By-Ay)^2)

The others formulas are very similar.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top