I have a unit vector, a distance and a coordinate and I would like to calculate the new coordinate given by adding the distance onto the coordinate in the given direction. How do I do this?
From stackoverflow
-
If with a unit vector, you mean a vector with distance 1. You can find the coordinate bij multiplying all coordinates with the distance.
V = V unit * distance V unit = (1/2 sqrt(3), 1/2) distance = 6 ==> V = (3 sqrt(3), 3) -
Multiply the vector by the distance then add the resulting vector to the point.
-
Here's some pseudocode, assuming you're using Cartesian coordinates.
new_coord.x = distance * unit.x + coord.x new_coord.y = distance * unit.y + coord.y
0 comments:
Post a Comment