dzhax Posted December 21, 2017 Share Posted December 21, 2017 Ok bare with me because I have no idea what this is actually called. If someone knows I will update the title. I am working on a site that will act as an out-of-game marketplace for in-game items. I want to ensure that the player is within the zone of the market in-game so I need an easy way to generate an array of valid coordinates the player could be within to access the market. Ideally i would like to run a function with a parameter specifying the radius of a square and another of the player's current geoID. Basic geometry would help if the geoID's were, in my mind, easier to predict. here is problem: Going North: geoID's increase by 512 points Going East: geoID's increase by 1 Going South: geoID's decrease by 512 Going West geoID's decrease by 1 I realize this is more of a math question then PHP but I have no idea where to start to account for the odd increase. //Generate the exchangeArea array of a 5x5 square around the centeral id specified in param2. $exchangeArea = getExchangeArea(3,117053149); //if player geoID equals one of the values in the exchangeArea array return true else false function getExchangeArea(int radius, int geoID) { . . . } I have attached a graphic showing all the geoIDs for the above example. Ignore the geoAlt that is just they players Y axis. So there is no confusion, North on this diagram is the right side of the image. Making the top West. Any help on where to begin, even if its helping me identify keywords to search on for this kind of formula, algorithm, equation... what ever it's called, would be greatly appreciated. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 4, 2018 Share Posted January 4, 2018 If you have specific increments for the different directions, then you just need to identify the first column for each row and then go 5 spaces over for each row. So starting from the center you go up 2 and left 2 for the top left corner, and just go from there. From the top left corner you just keep going down 1 to get the start of each of the 5 rows, and from each of those positions you go right 4 spots to get each square. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now