Link to home
Start Free TrialLog in
Avatar of Tagyourareit
Tagyourareit

asked on

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!
Avatar of ozo
ozo
Flag of United States of America image

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)
Avatar of Tagyourareit
Tagyourareit

ASKER

Hello,

thank you for fast replay.

And  what about heading direction? How can i calculate that?
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I mean as a move direction (which way you are facing at when traveling from one point to another) in degrees.