Advertisement

Author Topic: (Accepted) Grid Coordinate Function  (Read 3056 times)

0 Members and 1 Guest are viewing this topic.

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
(Accepted) Grid Coordinate Function
« on: 29 May 2007, 08:47:54 »
I edited an old OFP function, which would take a position and return a grid coordinate, for ArmA.  To use it, simply preprocess the function and then call it anywhere you need it.  It takes one parameter, a position.  Here's an example of how to use it:

Code: [Select]
gridCord = compile preprocessFile "gridcord.sqf";
MyGridPosition = [getPos player] call gridCord;
« Last Edit: 02 Sep 2007, 05:25:28 by hoz »

Offline Eymerich

  • Members
  • *
Re: Grid Coordinate Function
« Reply #1 on: 29 May 2007, 10:06:02 »
I have had a (fast) look to your functions.
Seems interesting and seems short too!
I'll try this evening.
Thank you!

Offline Blanco

  • Former Staff
  • ****
Re: Grid Coordinate Function
« Reply #2 on: 29 May 2007, 19:37:29 »
Very nice.
What's the difference between your script and posworldtoscreen and posscreentoworld?




Search or search or search before you ask.

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: Grid Coordinate Function
« Reply #3 on: 29 May 2007, 21:21:39 »
To be honest, I wasn't even aware that those functions existed.  The biggest difference with my function, though, is that it returns a string rather than an array.  This looks a little nicer in a radio message, for example. 

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Grid Coordinate Function
« Reply #4 on: 29 May 2007, 22:07:58 »
Blanco, this function these two commands have nothing in common.
These commands are based on the existance of a map control placed somewhere in an active display (dialog). So, as anyother control, its screen coordinates go from 0 to 1. Whith these functions to may transform world coordinates to screen coordinates [0-1, 0-1] so you can "draw" things on the map control.

Offline Cheetah

  • Former Staff
  • ****
Re: Grid Coordinate Function
« Reply #5 on: 29 May 2007, 23:49:25 »
Hmm is your one better than mine? Could be that your algorithm is alot better.
« Last Edit: 30 May 2007, 08:28:05 by Cheetah »
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Grid Coordinate Function
« Reply #6 on: 30 May 2007, 00:18:44 »
It is not a matter of better or not, the real matter is that the function posted here is only valid for OFP, while yours (Cheetah), with better or not better algorithm, is well suited for ArmA coordinates (quite weird coordinates btw).

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: Grid Coordinate Function
« Reply #7 on: 30 May 2007, 02:20:46 »
Mandoble, my function works in ArmA.  That is why I posted it.  It's based on an OFP funciton, but it has been altered to work in ArmA.  Go ahead and try it. 
« Last Edit: 30 May 2007, 02:24:32 by DucusSumus »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Grid Coordinate Function
« Reply #8 on: 30 May 2007, 08:13:03 »
You are using ["A","B","C","D","E","F","G","H","I","J"]; and this set is not what ArmA uses: W,X,Y,Z,A,B,C,....,O for Sara and Z,A,B,C,D for Rhamadi.

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: Grid Coordinate Function
« Reply #9 on: 30 May 2007, 08:44:48 »
Position in ArmA is zero at the beginning of A; west of A, x is a negative number in the position array.  This is because it is extremely unlikely for you to be in a location that has a grid coordinate outside of A - J.  Everything outside of that area is just ocean.  Inside the playable area, my function will return the correct grid coordinate.  You'll get errors in the WXYZ and KLMNO areas, but there is absolutely no land in those areas.  I could alter the function to make it include these areas, but I decided not to do so because it just isn't necessary.

Offline Cheetah

  • Former Staff
  • ****
Re: Grid Coordinate Function
« Reply #10 on: 30 May 2007, 20:58:52 »
Don't know if Rahmadi is on the negative side.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: Grid Coordinate Function
« Reply #11 on: 31 May 2007, 00:11:08 »
It is; I've tested it.  The beginning of the A coordinate is a zero in the position array.  West of that (into Z territory), it's negative. 

Offline bedges

  • Former Staff
  • ****
    • OFPEC The Editing Center
Re: Grid Coordinate Function
« Reply #12 on: 31 May 2007, 00:17:55 »
Quote
I could alter the function to make it include these areas, but I decided not to do so because it just isn't necessary.

did BI not include boats in arma? i don't have it so i can't check...

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: Grid Coordinate Function
« Reply #13 on: 31 May 2007, 00:28:34 »
There are boats, but the areas that are outside of the "regular" grid (A-J, 0 - 99) are wayyyy out there.  They're beyond all of the sub-islands even.  Honestly, I can't think of a single scanario that would have you out that far.  Even if I were to edit this function to make it include those areas, it doesn't need to be as complex as Cheetah's (though his works very well). 

Offline bedges

  • Former Staff
  • ****
    • OFPEC The Editing Center
Re: Grid Coordinate Function
« Reply #14 on: 31 May 2007, 00:36:38 »
i can think of several scenarios, for example a recreation of horatio nelson's last battle, where the player should be far enough out of range of land that it looks like the open ocean in all directions.

but then, they didn't have sat-nav in those days huh...  :scratch:

point is, if it's worth writing a function to do a job and if it causes little hassle to do that job in *all* circumstances, that's what you should aim for. limiting the function because you cannot foresee all the possible uses that the function could be put to by enterprising users is enforcing an unnecessary constraint on the resource.

if it does complicate the resource considerably or has an adverse effect on the engine, then that's a different story.