
How to calculate a point on a line in 3D - and my stigmata
Hi all,
Ok. I don''t have a stigmata - just a sales ploy to get more people to view this post so I would have a better chance of being answered.
I have an object I want to move from point x,y,z to point x1,y1,z1. In 2D I don''t have a problem with this - but once that darn z coord plops in there I am stumped.
So I create a vector from the two coords (the old position and the new position). I can calculate the magnitude of said vector. Now what? I''m not looking for code, but maybe someone can steer me in the right direction.
Oh, and I have the velocity of the object also. When the object is moving I think what I need to do is:
calculate the distance it should have moved since the last frame was drawn
add this distance to the last point it was located
calculate the x,y,z coords of the new coord
store this new coord as the last coord
I''m stuck on calculating the new x,y,z coord.
Thanks,
Dan

I don''t see how it differs from 2D movement.
x'' = x + vx * dt
y'' = y + vy * dt
z'' = z + vz * dt
where dt is the time step, (x,y,z) is the old position, (x'',y'',z'') is the new position, and (vx, vy, vz) is the velocity vector.
BTW, if you double-post, you can click on the ''Edit'' button at the top of your post, and check the ''Did you double-post?'' checkbox to remove it.
Cédric
x'' = x + vx * dt
y'' = y + vy * dt
z'' = z + vz * dt
where dt is the time step, (x,y,z) is the old position, (x'',y'',z'') is the new position, and (vx, vy, vz) is the velocity vector.
BTW, if you double-post, you can click on the ''Edit'' button at the top of your post, and check the ''Did you double-post?'' checkbox to remove it.
Cédric
It may help to have the formula for the magnitude of a 3D vector. That is sqrt(x^2+y^2+z^2). The magnitude of the projection onto the xy plane is sqrt(x^2+y^2) so your vector is sqrt(sqrt(x^2+y^2)+z^2)=sqrt(|x^2+y^2|+z^2)=sqrt(x^2+y^2+z^2). The magnitude of your velocity vector is your speed. So if you want to move at five units per second and dv is your displacement vector your velocity vector would be dv/|dv|*5 where |dv| is the magnitude of dv.
Keys to success: Ability, ambition and opportunity.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement