c# Moving from point A to point B in 3d space

Hello,


I am trying to move from point A(X1,Y1,Z1) to point B(X2,Y2,Z2) and calculate heading as well.
Move from point to point will be done incremental ... i will calculate distance between point in 3d space
and if distance in greater than let say 200 i will move in 2 steps (i hope i have explained it good).

I am coding in c# ... can someone post a function or a code snipped how could this be done in most efficient way?

Thnak you!
TagyourareitAsked:
Who is Participating?
 
ozoCommented:
If you are specifying heading as a unit vector, that would be  (X2-X1)/distance,(Y2-Y1)/distance,(Z2-Z1)/distance
0
 
ozoCommented:
The distance between A and B would be sqrt((X1-X2)^2+(Y1-Y2)^2+(Z1-Z2)^2)
to move in 2 steps, the first step would be to point C((X1+X2)/2,(Y1+Y2)/2,(Z1+Z2)/2)
0
 
TagyourareitAuthor Commented:
Hello,

thank you for fast replay.

And  what about heading direction? How can i calculate that?
0
 
TagyourareitAuthor Commented:
I mean as a move direction (which way you are facing at when traveling from one point to another) in degrees.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.