Djokovic
Djokovic

Reputation: 1061

Finding 3D velocity vector

How do I find the 3D velocity vector? I have the the starting position, the ending position and the speed of the projectile.

Also, how do I find the velocity vector if the target is moving?

Any help is much appreciated.

Upvotes: 1

Views: 15681

Answers (1)

Adam Liss
Adam Liss

Reputation: 48310

If the components of the positions are x, y, and z, then you can decompose the movement of the missile:

dx = endPosition.x - startPosition.x
dy = endPosition.y - startPosition.y
dz = endPosition.z - startPosition.z

You can find the total movement:

d = sqrt(dx*dx + dy*dy + dz*dz)

Then you can calculate the velocity vector:

vx = dx/d * missileSpeed
vy = dy/d * missileSpeed
vz = dz/d * missileSpeed

Upvotes: 6

Related Questions