Reputation: 3105
I need to measure angle between two vectors. I have .kml
file that is filled with Latitutes and longitutes
54.90627884784906, 23.98023512082725
54.90568158443394, 23.98021489919758
54.9055211876991, 23.97995622451836
...
So here how I made my vectors:
Vector3 firstVec = new Vector3(new Point3((float)54.90627884784906, (float)23.98023512082725, 0),
new Point3((float)54.90568158443394, (float)23.98021489919758, 0));
Vector3 secondVec = new Vector3(new Point3((float)54.90568158443394, (float)23.98021489919758, 0),
new Point3((float)54.9055211876991, (float)23.97995622451836, 0));
here how I measure angle between two vectors
double angle = firstVec.angle(secondVec);
and here's my result:
0.9824845194816589
Here's image image on my phone representing these coordinates.
Obviously my angle is not correct. How to calculate it?
Upvotes: 0
Views: 1320
Reputation: 1582
angle between two vector is Math.acos(
Dot Product)
result is in radiants, thus you'd multiply by Math.Pi/180
Upvotes: 1
Reputation: 308998
Your vectors are wrong.
Lat and lon are spherical angle coordinates. I'd recommend that you convert them to rectangular coordinates in 3D before you begin. Once you have those it's easy to calculate the angle in radians using the dot product.
You should also know that lat and lon are expressed in degrees - convert them to radians before you start using them in trig functions.
Upvotes: 2