Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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,...)

Thats a dense, yet slow way of indexing things typically people just set bit ranges for certian things:

o = (x << 0) | (y << 8) || (z << 16)

x = (o >> 0) & 7

y = (o >> 8) & 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

  • 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...)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.