Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > General > Chit Chat
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Chit Chat The place for open discussions.


Help with MAP LOGIC


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-30-2008, 11:37 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default Help with MAP LOGIC

I'm trying to make sense of some map Logic...
Imagine a map, divided in cells, extending from -250 to 250, including 0,in both x and y axes...
Its easy obtaining the total amount of squares.
(250*250+1) will give me the number of Lines and of collumns, so the total amout of cell is (rows*Collumns)....
In this case:
501*501=251001

For some reason, I HAVE TO USE THIS IN A SEARCH, but Then it gets complicated....
How do I get the Coordinates for a specific cell, trough its number...
Imagine I need to convert cell 36862 to X:Y , HOW????
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #2 (permalink)  
Old 05-31-2008, 12:01 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 702
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Hi Paulo,
Here you are.

Code:
index=36862
row=Int(index/501)
col=index Mod 501
Best regards
Attached Files
File Type: sbp MapCalc.sbp (1.6 KB, 5 views)
__________________
Klaus
Switzerland

Last edited by klaus : 05-31-2008 at 12:05 AM.
Reply With Quote
  #3 (permalink)  
Old 05-31-2008, 01:10 AM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Thanks, but it shed litle light for what i need..
you forgot that I have negative values, referenced to a 0 colun and a 0 row, so my map look a litle like this:

-3 -2 -1 0 1 2 3
+--+--+--+--+--+--+--+
3 |01|02|03|04|05|06|07|
+--+--+--+--+--+--+--+
2 |08|09|10|11|12|13|14|
+--+--+--+--+--+--+--+-
1 |15|16|17|18|19|20|21|
+--+--+--+--+--+--+--+
0 |22|23|24|25|26|27|28|
+--+--+--+--+--+--+--+
-1 |29|30|31|32|33|34|35|
+--+--+--+--+--+--+--+
-2 |36|37|38|39|40|41|42|
+--+--+--+--+--+--+--+
-3 |44|45|46|47|48|49|50|
+--+--+--+--+--+--+--+

Only a LOT larger...
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing

Last edited by Cableguy : 05-31-2008 at 01:15 AM.
Reply With Quote
  #4 (permalink)  
Old 05-31-2008, 08:43 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 702
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

No problem.

The previous code
Code:
index=36862
row=Int(index/501)
col=index Mod 501
becomes

Code:
rowo=-177     ' row
colo=39       ' col
row0=-250     ' first row number
col0=-250     ' first col number 
rownb=501     ' number of rows
colnb=501     ' number of cols
index=(rowo-row0)*colnb+col0)  ' =36862  cell index

row=Int(index/501)+row0   ' calculated row
col=index Mod 501+col0    ' calculated col
Best regards
Attached Files
File Type: sbp MapCalc.sbp (1.6 KB, 4 views)
__________________
Klaus
Switzerland
Reply With Quote
  #5 (permalink)  
Old 05-31-2008, 05:25 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

Yes, it works fine, but could you explain a bit your logic...
How the actual calculations works....
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #6 (permalink)  
Old 05-31-2008, 09:15 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 702
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Hi Paulo,

I have joined a Word file with some explanations, hope its more clear.

Best regards.
Attached Files
File Type: zip MapCalc.zip (4.3 KB, 7 views)
__________________
Klaus
Switzerland

Last edited by klaus : 06-01-2008 at 12:23 PM.
Reply With Quote
  #7 (permalink)  
Old 06-06-2008, 11:08 AM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 486
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Klaus you must be a math-magician!
I like Cableguy couldn't see how your code works, but the explanation was great and you made it look so simple. Personally I hate maths and always struggle with it

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #8 (permalink)  
Old 06-06-2008, 06:46 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 702
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

Hi RandomCoder,
I am glad to hear that my explanations were clear.
I am an engineer and of course like maths.

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:01 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0