Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

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

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 Discussions
Thread Thread Starter Forum Replies Last Post
How to get keypress in form atiqe Mobile Java General 1 2007-06-06 15:39
Read all details of Inbox Messeges Asif Nazir Symbian Networking & Messaging 5 2008-03-21 20:49
OMA Client Provisioning MAC koayst OMA DM/DS/CP 1 2003-09-25 04:38
receiving SMS. ramey General Messaging 6 2008-03-18 15:37
Calculating dates using Calendar cs04rrj Mobile Java General 2 2008-01-17 21:15
 
Powered by MediaWiki