Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2016-04-01 13:23:14, last edited by Hexagon (2016-04-07 19:40:11)

Hexagon
Member
Joined: 2015-04-22
Posts: 1,213

Non-overlapping & overlapping equations for grids, stairs & more!

Myself and a few others a while back were looking for a method or equation to draw a grid on an EE world, and have it fit perfectly (i.e no cut off cells.)

This equation, when true, should indicate whether or not the grid that you are choosing to use will perfectly fit on your world. Let me know if there's any errors, as I didn't check it tonnes.

Let (in terms of full blocks):
m = world width
n = world height
p = grid width
q = grid height

This will assume that your world has a one block border around the entire world. The grid will have a border of one block (i.e the minimum amount of blocks for a grid to appear.)

jCaZVv6.jpg

is defined where JU3NN0j.jpg

Everything after this equation is only useful if you want to customize the equation, or want different border sizes.

or in general for the y-direction:

jys7T56.jpg

where, KUk09vD.jpg

r1 = top border
r2 = bottom border
u = grid border (bottom)

in general for the x-direction:

JhC1wez.jpg

where, 9HTNm52.jpg

t1 = left border
t2 = right border,
s = grid border (right)

and, Uo0PZqj.jpg

Therefore, the following equation can be derived, for any p x q grid on m x n world with r, s, t, u borders it will fit perfectly if:

b4i6e5E.jpg

Note: canvas size of n and m do include borders into their calculation: take the size of the canvas including all of the borders. Also, if u and s are 0, the equation will still be defined but having no grid borders doesn't make much sense (unless you have a specific purpose for that.)

The result from each sub-expression (divided by the + sign) is the block overflow in each direction respectively. From there, you can increase or decrease the canvas size by the result of that expression to accommodate your grid.

The following equation shows how many blocks it will take to draw the grid:

PdMQijC.jpg

where the variables follow the same restrictions as previously mentioned.

If the grid overflows from the canvas, then, well, things get a bit complicated. You can use the following to calculate a grid that doesn't overflow too, but it's a bit wasteful. You can use this equation to calculate how many blocks it would take to draw that monster:

y4tuYuU.jpg (I didn't fully check this yet!)

If you want to resize the grid, and have every grid item the same size after the resize, then you must resize in factors of:

wpAD2t5.jpg (for the x direction, where x > p, x > 2, and x in N)

rVm5GFJ.jpg (for the y direction, where y > q, y > 2, and y in N)

For example, if you wanted to resize a canvas of 20 blocks horizontally and the p-sized cell 6 units, it would have to be (20-2)/(6+1) = 18/6 = a factor of 3 units. So, you could resize it by 3 units, 6, 9, 12...

First attempt at mathematically proving this (might be completely wrong; take it with a grain of salt):

Hidden text

Offline

Wooted by: (4)

#2 2016-04-01 16:07:10

Hexagon
Member
Joined: 2015-04-22
Posts: 1,213

Re: Non-overlapping & overlapping equations for grids, stairs & more!

Zumza wrote:

(m - 1) mod p + (n - 1) mod q = 0

Unfortunately I wasn't able to arrive at that simplification of the formula, or correction. I'm not super good with math, so perhaps my reasoning is wrong.

Would you be able to show step-by-step how you arrived at that?

Offline

#3 2016-04-01 16:41:12, last edited by Zumza (2016-04-01 16:43:08)

Zumza
Member
From: root
Joined: 2015-02-17
Posts: 4,656

Re: Non-overlapping & overlapping equations for grids, stairs & more!

Sorry I'm on drugs(literally).

Lets say we have a world with the width of n and with the height of m.
EE worlds have borders: top, left, bottom and right.
The top and bottom borders are made of n blocks
The left and right boarders are made of m blocks

To determine the remaining blocks we must subtract the borders:
so n * m - 2n - 2m - 4(the junctions) = (n - 2) (m - 2)

p is the width of the desired grid and q is the height of it
p and q must divide n respectively m perfectly.
so (n - 2) mod p + (m - 2) mod q = 0


Everybody edits, but some edit more than others

Offline

#4 2016-04-01 17:35:19, last edited by Hexagon (2016-04-04 17:33:41)

Hexagon
Member
Joined: 2015-04-22
Posts: 1,213

Re: Non-overlapping & overlapping equations for grids, stairs & more!

Zumza wrote:

Sorry I'm on drugs(literally).

Lets say we have a world with the width of n and with the height of m.
EE worlds have borders: top, left, bottom and right.
The top and bottom borders are made of n blocks
The left and right boarders are made of m blocks

To determine the remaining blocks we must subtract the borders:
so n * m - 2n - 2m - 4(the junctions) = (n - 2) (m - 2)

p is the width of the desired grid and q is the height of it
p and q must divide n respectively m perfectly.
so (n - 2) mod p + (m - 2) mod q = 0

Ah I see now. I think we're doing two slightly different operations (one where the border block is inside of the p-sized cell, and the latter where it is not contained within):
- Mine considers [X][ ][ ][ ][X][ ][ ][ ][X][ ][ ][ ][X] valid because for n = 13 and p = 3, (n-1) mod (p+1) is equal to (13-1) mod (3+1) = 12 mod 4 = 0
- Yours considers [X][ ][ ][ ][X][ ][ ][ ][X][ ][ ][ ][X][X] valid because for n = 14 and p = 3, (n-2) mod p is equal to (14-2) mod 3 is 12 mod 3 = 0 which mine does not consider; the graph is fully contained within the canvas, and the last block which would have been cut off isn't because it is now part of the border.

However, both equations would consider [X][ ][ ][X][ ][ ][X][ ][ ][X] valid, where p = 2 and n = 10 which...

Offline

Wooted by:

#5 2016-04-06 20:23:22, last edited by Hexagon (2016-04-07 02:20:12)

Hexagon
Member
Joined: 2015-04-22
Posts: 1,213

Re: Non-overlapping & overlapping equations for grids, stairs & more!

For stairs,

HSXUlqU.jpg where m = length of canvas, p = length of step, r = amount of blocks each step is overlapping the previous. If this equation is true, there will be no overlapping in the x-axis. You can use a negative value for r, if needed.

10IwV3y.jpg where q = height of step, n = height of canvas. If this equation is true, there will be no overlapping in the y-axis.

If you want to calculate the area of hollow steps (i.e steps with nothing underneath them) use p * q * n, where p = length of step, n = height of canvas, q = blocks in between each step (normally one.)

If you want to calculate the area of steps with blocks underneath them (i.e filling all empty space) then use:

OLEUzA1.jpg

where the variables are the same, and s = i (in this case i is not an imaginary number.) If you don't like sums, you can use hGBtcyF.jpg instead (kudos to Wolfram|Alpha for converting the sum into a summation formula.)

Offline

#6 2016-04-06 21:32:06

Abelysk
Guest

Re: Non-overlapping & overlapping equations for grids, stairs & more!

What is this

Wooted by: (3)

#7 2016-04-06 22:28:01

Xfrogman43
Member
From: need to find a new home
Joined: 2015-02-15
Posts: 4,174

Re: Non-overlapping & overlapping equations for grids, stairs & more!

Uh, something is going wrong with this:
ZmX0p6f.png

I didn't even do anything...


zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

Wooted by: (5)

#8 2016-04-07 01:49:16, last edited by Hexagon (2016-04-07 02:23:45)

Hexagon
Member
Joined: 2015-04-22
Posts: 1,213

Re: Non-overlapping & overlapping equations for grids, stairs & more!

Xfrogman43 wrote:

Uh, something is going wrong with this:
http://i.imgur.com/ZmX0p6f.png

I didn't even do anything...

Oh shoot, I didn't check the transparency with the default Coal theme. I'll have to make those on a white background soon--a workaround in the meantime is to use the snow theme. Thanks for noticing that!

Kefka wrote:

What is this

These equations help world creators make stairs and grids, by using mathematical patterns to determine if they will fit in your world, based on the requirements that you have. It reduces trial and error to just an equation being non-zero, rather than having to draw the entire grid every time in your world, which can be frustrating. Moreover, it can allow bots to draw grids/stairs that fit perfectly inside of a certain shape, allowing dynamic multiplayer maps.

If you need (or anyone) needs any help using the equations, or wants to know how I arrived at the solution, let me know as I didn't include any diagrams yet and so my language is a bit vague as to what the variables represent. The validity of the equations isn't guaranteed, but I'll be working with them in other cases to see if they fail.

Offline

Wooted by:

#9 2016-04-07 23:54:21

Anch
Member
Joined: 2015-02-16
Posts: 5,447

Re: Non-overlapping & overlapping equations for grids, stairs & more!

Hexagon wrote:

These equations help world creators make stairs

no please

Offline

Wooted by: (3)

#10 2016-04-08 06:21:21

Kaleb
Formerly Kaleb123
From: California of America
Joined: 2015-02-19
Posts: 1,263

Re: Non-overlapping & overlapping equations for grids, stairs & more!

Umm. What is this even about like. Ok.

Offline

#11 2016-04-08 15:39:41

Hexagon
Member
Joined: 2015-04-22
Posts: 1,213

Re: Non-overlapping & overlapping equations for grids, stairs & more!

Kaleb123 wrote:

Umm. What is this even about like. Ok.

If you want to make a grid, or a whole bunch of minigame containers, and don't want any that are chopped off, just plug in the parameters into the equation and if it equals 0, it'll fit perfectly.

Offline

Wooted by:
Hexagon1460126381594331

Board footer

Powered by FluxBB

[ Started around 1732073706.0948 - Generated in 0.094 seconds, 13 queries executed - Memory usage: 1.61 MiB (Peak: 1.79 MiB) ]