Archived

This topic is now archived and is closed to further replies.

xyz

This topic is 5021 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I like to know how to move an object from source to destination in xyz plane. To be more specific....... If I want to shoot an object the bullet path has to be calculated. I''m looking for a solution. thanks - Dhanyu

Share this post


Link to post
Share on other sites
Well, assuming nothing wacky, you''ll have a source vector and a destination vector, each with x, y, and z components. The displacement between the 2 (i.e. the difference) can be found by having a vector (vDestination - vSource).

You can derive a line equation from the start and end by determining slope in the x and z directions. This will probably be of the form y = f(x, z). If you have a velocity vector, you can also come up with a set of functions x = f(t), y = f(t), and z = f(t). These will give you a set of parametric equations that define your line. But generally the vector is enough, unless you need to do some sort of time based prediction or something.

That was kind of quick, if I lost you just say so.

Share this post


Link to post
Share on other sites
HI,

Thankx Promit. Let me express what I learned from your answer.

if source is X Y Z and destination is X1 Y1 Z1

displacement = X-X1, Y-Y1, Z-Z1

so if I move my object in loop till while
i != X-X1 i++ or i--
j != Y-Y1 j++ or j--
k != Z-Z1 k++ or k--

this would give me straight path to the destination.

this is what I understood. Thank you for your reply. Please let me know if I''m wrong.

- Dhanyu

Share this post


Link to post
Share on other sites
More or less, yeah. The only things to note:

i, j, and k are almost certainly floating point variables, so you can add something other than 1 to them, any number in fact (this is where a velocity vector comes in). Instead of checking i != X - X1 you should probably check that i < X - X1 or whatever, because there''s a possibility of overshooting the final target (floating point inaccuracies and such). Then when you do reach or pass the end point, set the coordinates to the end point. This will make sure you don''t overshoot your target.

Share this post


Link to post
Share on other sites