0
$\begingroup$

I'm working on an algorithm which involves two vectors in 3D space. They're both moving towards a single point within their respective directions - I need to make sure that they both hit the same point on the same iteration.

So, in this case, we have the position vector $P_0$ which is moving in the direction of the vector $u$. Likewise, the position vector $P_1$ moves in the direction $v$.

At some point in time, $P_0$ will reach the point $p$. The same goes for $P_1$, however the time at which they will reach $p$ is likely to be different.

Is there a way which I can make the two direction vectors $u$ and $v$ produce the same length (while maintaining their original directions), so that they will both hit $p$ on the same iteration?

$\endgroup$

2 Answers 2

0
$\begingroup$

You can do one of two things. You can make sure both points start out the same distance from the intersection point. Call the intersection point $P_2$ You can compute the distance $|P_2-P-0|=d$ then move $P_1$ so it is the same distance away. The formula is $P_1=P_2-d\frac v{|v|}$. The other choice is to make them move at different rates so they arrive the same time. You haven't talked about how fast $P_0$ moves in the direction $u$, but you must have a speed involved. Scale the speed of $P_1$ so it arrives the same time.

$\endgroup$
0
$\begingroup$

If you set $u_1$ to the vector from $P_0$ to $p$, and set $v_1$ to the vector from $P_1$ to $p$, then the two vectors will both "reach" $p$ in one timestep.

You seem to want more than one timestep. If you would prefer $n$ timesteps, for some integer $n > 1$, then set $$u = \frac 1n u_1$$ $$v = \frac 1n v_1$$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .