Question

I'd like to scale GPS coordinate by given direction and length. E.g. I have two points A,B. I know their GPS position (also in cartesian format) and I'd like to change the length of line AB by 1.5 where point A should be intact and B should move to new position B'

any ideas?

Was it helpful?

Solution

I am not sure if I understand your question. Do you want to compute a location which is on the line between two known points A and B but half the distance between A and B behind B on that line?

Compute the vector difference between A and B: if A has coordinates latA, lonA, and B has coordinates latB, lonB than the difference L = B-A has coordinates latL = latB-latA and lonL = lonB-lonA. The point you are looking for than has coordinates latA + 1.5 * latL, and lonA + 1.5 * lonL.

This uses the representation of the line passing through A and B as X = A + l * (B-A); all the points X satisfying the vector equation are on the line. Of course this assumes a Cartesian coordinate system. However, for short distances the result should be ok.

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