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

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

Heading should be:  -7423

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
Asked:
Tagyourareit
  • 4
  • 3
1 Solution
 
ozoCommented:
How are you expressing a direction in 3-D space?
What does a heading of -7423 mean?
0
 
TagyourareitAuthor Commented:
Hello,

How are you expressing a direction in 3-D space?

Open in new window

What do u mean by that?

What does a heading of -7423 mean?

Open in new window

Its a short ... Signed 16-bit integer
0
 
TagyourareitAuthor 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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
ozoCommented:
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
 
TagyourareitAuthor 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);
        }

Open in new window

0
 
ozoCommented:
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
 
TagyourareitAuthor 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.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now