How do I work with $2$D vectors where the origin is not at $(0, 0)$?

415 Views Asked by At

EDIT: It seems that what I really wanted to know about was directed line segments, not vectors.

I'm a self-taught programmer working with the Travelling Salesman Problem. On developing an idea for an algorithm I realised I needed to use vector maths. I have no mathematical education beyond high-school, so I don't have any prior knowledge to start from in this area.

My problem involves taking a particular vector in $2$D space which does not originate from $(0, 0)$, and then finding the signed angular difference between this vector and other vectors that also have the same origin.

In the course of researching the problem I realised that $2$D vectors are generally assumed to have an origin of $(0, 0)$, which was not obvious to me at first.

Do I need to translate the whole set of points so that the 'origin point' coincides with $(0, 0)$, or can I work with the vectors as they are.. accounting for a non-standard origin?

I don't have the vocabulary or understanding to know that there are no answers already posted on this topic, though I have searched. Please point me to them if there are. I have found answers (including this one) on Stack Overflow that address the programming side of it, but they don't address the theory behind my question.

Having done a full day of googling this I can't find any explanations which deal with this specific case. It's doing my head in and I would really appreciate some help with this.

EDIT:

To clarify further:

It seems to me that when working with cartesian coordinates, vectors are assumed to originate from (0, 0), as below...

enter image description here

The problem I'm working with is like this...

enter image description here

..where the angle from A to C is defined as the 'zero angle' and the angles from A to B, D and E are measured relative to the zero angle as signed clockwise angles.

In all the equations, as in the suggested answer, only two points are used (x and y), and to me it seems to be assuming an origin to measure the angle from.

1

There are 1 best solutions below

1
On BEST ANSWER

This may or may not help you, but vectors do not have “an origin.” They might be drawn or described by saying where they “begin” and “end,” but they simply represent a displacement and have no actual location in space.

The vector of length $2$ with northeast direction can be written as $\langle\sqrt2,\sqrt2\rangle$. If that vector is “placed” with its tail at the origin, its tip will be at the point $(\sqrt2,\sqrt2)$, and sometimes vectors are written with parentheses instead of angle brackets, so it might seem like there’s a convention to assume they begin at the origin.

If your application needs a mathematical object that “goes from point $P$ to point $Q$,” you need a directed line segment, not just a vector.

In any case, if you need to find the angle between two vectors, you can use the formula given by herb steinberg in a comment.