• Status: Solved
• Priority: Medium
• Security: Public
• Views: 148

# Get heading between two points

Hello,

Could someone please try and solve this math problem for me:

i have two coordinates A and B and i need to calculate heading between those two.

Now by heading i want to get direction i am facing if i go from point A to point B.

Now i have checked heading in application and it goes like this:

X1 = 67749,79
Y1 = -75603,24
Z1 = -2854,271

X2 = 67801,95
Y2= -75648,37
Z2 = -2823,197

This i get from one application (i dont have source code for it so i dont know how heading is calculated but it should be correct).

tried with ATAN2 but it doesnt return same resoult.

Thank you!
0
Tagyourareit
• 4
• 3
1 Solution

Commented:
How are you expressing a direction in 3-D space?
What does a heading of -7423 mean?
0

Author Commented:
Hello,

How are you expressing a direction in 3-D space?
What do u mean by that?

What does a heading of -7423 mean?
Its a short ... Signed 16-bit integer
0

Author Commented:
I've requested that this question be deleted for the following reason:

Its a badly formulated question. Let me think about it and will post better one.
0

Commented:
A direction in three-dimensional space is usually expressed with two or three real numbers.  e.g. as altitude&azimuth or as direction cosines or as a unit vector, ...
How are you describing a direction as a single integer?
0

Author Commented:
Well function i have is like this:

public static short GetHeading(float x, float y)
{
return (short) (Math.Atan2(y, x)*32768/Math.PI);
}
0

Commented:
That's a two dimensional direction on a circle divided into 65536 sectors , whereas your points had 3 dimensions.
If you ignore the Z you can sort of close to -7423 by applying your function to  GetHeading(X2-X1,Y2-Y1), but if you head in that direction from
X1 = 67749,79
Y1 = -75603,24
Z1 = -2854,271
you would not go to
X2 = 67801,95
Y2= -75648,37
Z2 = -2823,197
because you would still be at
Z1 = -2854,271
0

Author Commented:
I will accept the answer its partially what i want.

Thank you for now.
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.