CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2014
    Posts
    205

    reverse function

    Hello,

    I have code for conversion of longitude and latitude and I need help to reverse the function so it will work in opposite direction:

    Code:
    float LongitudeDeg = argv[1]; // some longitude
    float LatitudeDeg = argv[2]; // some latitude
    uint32_t u,v,l,n;
    l=15; // l range is 2-29
    
    LongitudeData = int(0.5 + (180 + LongitudeDeg) * (0x2000000 / 15));
    LatitudeData = int(0.5 + (90 - LatitudeDeg) * (0x8000000 / 45));
    
    if ( LongitudeData > 0x30000000)
    	LongitudeData -= 0x30000000;
    if (LongitudeData < 0)
    	LongitudeData += 0x30000000
    
    if ( LatitudeData > 0x20000000 )
    	LatitudeData -= 0x20000000;
    if ( LatitudeData < 0 )
    	LatitudeData += 0x20000000);
    
    n = 30 - l;
    u = LongitudeData >> n;
    v = LatitudeData >> n;
    On start of the code we know longitude,latitude and l. And the result is u and v. And I need function when I will know the u and v, possibly l too, to calculate longitude, latitude.

    Can you help with it?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: reverse function

    What are "physically" these LongitudeDeg, LatitudeDeg, LongitudeData, LatitudeData, l, u and v?
    Victor Nijegorodov

  3. #3
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: reverse function

    Basic algebra....not really a programming question....
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured