Posted April 16, 20169 yr This problem is more of a mathsy one that a forge one but it's been bugging me for so long now that I think I am incapable of noticing the solution Let's say I have an integer set of coordinates, each ranging from 0 to some independent finite limit (which may be different for each. This can be thought of as an N dimensional grid with coordinates (i, j, k, ...) and lengths (I, J, K, ...) . In this case each coordinate that can be occupied/intersect of the grid can be counted with an ordinal assigned by o=i+j*I+k*I*J+... . this is useful wen trying to assign a metadata value or some such. The problem I'm having is figuring out a way of reversing this operation to get the original (i,j,k,...) given the ordinal and (I,J,K,...) github
April 16, 20169 yr Thats a dense, yet slow way of indexing things typically people just set bit ranges for certian things: o = (x << 0) | (y << || (z << 16) x = (o >> 0) & 7 y = (o >> & 7 z = (o >> 16) & 7 But you way it's similiar but can't easily do the shifts. So: o = x+y*(X)+z*(X*Y) x = o % X y = floor((o % (X*Y))/X) z = floor((o % (X*Y*Z))/(X*Y)) Complicated and ugly, but should do what you want. I do Forge for free, however the servers to run it arn't free, so anything is appreciated. Consider supporting the team on Patreon
April 16, 20169 yr Author Thanks, that's been bugging be for ages. think I'd just looked at it for too long to notice as I said. Did initially think of just packing like you say but it wound up being important that they remain in order and without gaps (various rng operations etc...) github
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.