# Calculating endpoints of directional vector

I have the feeling the solution is horribly obvious, but I’m having trouble understanding a bit of vector math: if I want a vector representing the distance between two points, I do something like this:

``````Vector3 origin;
Vector3 destination;
Vector3 direction = (destination - origin).normalized * Vector3.distance(origin, destination);
``````

So here’s where I’m confused: if someone hands me direction without any of the accompanying values, how would I calculate origin and destination? Would origin simply be direction.normalized?

A ray or line is an origin and a direction - you CAN’T build a true line without the other, and you can’t calculate one without the other.

But without knowing your application, you might be able to assume one. A direction vector that is used as a speed has its origin at the object. So sometimes the context lets you know what the origin is supposed to be.

Care to offer some more detail?

You shouldn’t think of the vector you get by subtracting destination from origin as a “direction vector”. It’s more than that. It’s a vector representing the relative positions of the two points or “how to get from origin to destination”. The direction vector is what you get when you normalise the relative position vector.

For any such relative position vector, there are an infinite number of origin-destination pairs that would give the exact same relative position vector when you subtract them. This is obvious from the fact that whatever your origin, you can add the relative position vector to get a new destination.

Therefore, you can’t go backwards and what you ask for is not possible.

Another way to look at it is that you start with 6 pieces of information (2 sets of 3D coordinates). When you subtract them to get your relative position vector, you end up with just 3 pieces of information. Information must, therefore, have been lost and you cannot expect to be able to reconstruct the 6 that you started with.

So, what you ask for is not possible. You can’t work out the origin or destination from such a vector.