Calculating incremental coordinate change along a 3D vector

371 Views Asked by At

This is pretty trivial, but I've not managed to resolve it to my satisfaction and it has reached the stage where fresh eyes are definitely useful!

I have an xyz point, and a 3D vector originating at that point. I would like to be able to shift one of the coordinates by a fixed amount, and calculate the change in the other two coordinates as I traverse the vector.

For example:

Starting at the xyz point (24.2778,30.0526,105.738) I have a vector with components (15.7618,19.4226,68.7535).

I would like to move along the vector 2.60662 in z, and then calculate the corresponding points for x and y (still sitting along this original vector).

Is it correct to calculate the unit vector in each direction, and then simply do:

new x = original_x + (x_unit_vector * 2.60662)

new y = original_y + (y_unit_vector * 2.60662)

Doing this yields a new xyz point at (24.8393, 30.7446, 108.188) which seems reasonable, but I'd like to be more confident in my approach than that!

Many thanks.

1

There are 1 best solutions below

1
On BEST ANSWER

Suppose you have a point $P$, and you have a 3d vector pointing from it denoted by $N$. Then the equation for the line represented by those two components is $X=P+Nt$, where t is some number. And so you have $$X_x=P_x+N_x t\\X_y=P_y+N_y t\\X_z=P_z+N_z t$$ When $t=0$, then you have the location of your initial point. Now you have shifted one of these values, let's say the $P_x$ value by $n$, then your new point is going to be at $P_x+n$. So now you have $$P_x+n=P_x+N_xt\\t=n/N_x\\X_y =P_y+N_y(n/N_x)\\X_z =P_z+N_z(n/N_x)$$The way you wrote it doesn't necessarily work because you are implying that to get the new $z$ coordinate, all you have to do is do the new z = original_z + (z_unit_vector * 2.60662), which isn't true.