# Calculating two perpendicular vectors between two points (maybe vector decomposition?)

I think this is a fairly basic question, but I'm pretty bad at math so I've spent several hours trying to work this out using my poor trig skills since I don't understand vector math at all. Maybe this is vector decomposition, it sounds kind of like it from the wikipedia article, but it doesn't explain how to do it.

If I have two points and I want to get from one point to the other, but the path must consist of two perpendicular vectors, e.g:

How do I calculate the magnitude and direction of those vectors? In the example the first vector is at $315^\circ$, but it could be any number and it's entered by the user (this is for a program I'm writing) so I have no choice about what it is.

-

Given your initial two points $P_1$ and $P_2,$ carefully write their x-y coordinates, and find the midpoint of the line segment between them, call that point $C.$ The $x$ coordinate of $C$ is half the sum of the $x$-coordinates of $P_1$ and $P_2,$ the $y$ coordinate of $C$ is half the sum of the $y$-coordinates of $P_1$ and $P_2.$ The circle centered at $C$ with radius half the distance between $P_1$ and $P_2$ passes through both points.

Any line passing through $P_1$ does one of three things:

(A) it is perpendicular to the segment $P_1 P_2,$ your task is impossible

(B) it passes directly through $P_2,$ after passing through $C$ halfway along, you are done,

(C) it meets the circle at some second point $Q,$ in which case the line segment from $P_1$ to $Q$ and the line segment from $Q$ to $P_2$ are perpendicular.

So you need to refresh your skills in finding the equation describing a circle, given center and radius. Then you need to figure out how to write the equation of a line, given the "angle" you are talking about when the line leaves $P_1.$ Finally, you need to figure out how to find the intersection point $Q.$

Notes. If I am correct about the meaning of your "angle," the following are useful. Suppose the point $P_1$ has coordinates $(x_1,y_1),$ and your directed line leaves that point at angle $\beta.$

Then, the parametrized version of the path, parameter $t,$ is $$x = x_1 + t \cos \beta, \; \; y = y_1 + t \sin \beta.$$ The equation version of the path is $$(x-x_1) \sin \beta = (y-y_1) \cos \beta.$$

-
Thanks, I worked it out with your help. –  Michal Dec 14 '11 at 19:56