You Are Here:

Community: Wiki

This page was last modified on 11 May 2008, at 19:26.

How to calculate the direction of movement

From Forum Nokia Wiki

To calculate the direction of movement enough to know coordinates of two consistently received landmarks.

If you use the Cartesian coordinate system and adopt the longitude on the axis "X", latitude on the axis "Y" - then it is possible to calculate the vector of movement.

The following image demonstrates how to calculate vector of the movement and the angle of the vector:

Image:DirectionOfMovement.png

Depending on the direction, you must perform correction of meaning angle.

The following code snippet demonstrates how to calculate the angle of the movements (relative to north), knowing consistently received two landmarks.

TReal alpha; // result
 
// calculate vector coordinates
TReal y = LatitudeB - LatitudeA,
x = LongitudeB - LongitudeA;
 
// hypotenuse
TReal sqrtResult = 0;
Math :: Sqrt( sqrtResult, x * x + y * y );
TReal angle;
Math :: ASin( angle, Abs( x ) / sqrtResult );
alpha = angle * 180 / KPi; // angle from North in degrees
 
// correction
if( x > 0 )
{
// I or IV quadrant
if( y < 0 )
{
// IV quadrant
alpha = 180 - alpha;
}
}
else
{
// II or III quadrant
if( y > 0 )
{
// II quadrant
alpha = -alpha;
}
else
alpha = alpha - 180;
}

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fJavaE5fVerifiedE5fE28PortuguE25C3E25AAsE29X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ