Math blocks

22
Mathematics of blocks Author: lrcvs / Xkrouhn 01.06.2015

Transcript of Math blocks

Page 1: Math blocks

Mathematicsof

blocks

Author:

lrcvs / Xkrouhn

01.06.2015

Page 2: Math blocks

Acknowledgements

A's friends: http://www.freebasic.net/forum

In alphabetical order:dodicatfxmRichard

For the interest and development of the program with FreeBasic.

Page 3: Math blocks

The math block is child's play

As shown in the figure, the blocks are composed of elements, which arethe work unit with blocks.

1 element = 1 unit

With the elements, we can create rows or columns.

The row is a set of horizontally grouped elements.

The column is a set of grouped elements vertically.

Grouping rows or columns, formed surfaces or levels.

If we combine various levels, we get a block.

The Dimensions

Some science fiction movies with space matters, almost always tend to say this in one or another dimension

We define the dimensions 1D, 2D, 3D, 4D, 5D and 6D ....

1D is formed by rows or columns of elements.

2D: this consists of rows and columns of elements.

3D: This consists of rows and columns, grouped into levels or layers.

Page 4: Math blocks

4D: consists of several blocks, 3D grouped in rows.

5D: consists of several blocks, 3D grouped in rows and columns.

6D: consists of several blocks, 3D grouped in rows and columns, and levels.

Page 5: Math blocks

Linking blocks would form on 7D, 8D, 9D, etc, etc ..

These three figures are equivalent, all have 27 elements. Can transform the various ways (dimensions, blocks, 1D, 2D, 3D ...) different, but still have the same elements, they are all equivalent, keep the same number of elements.

Page 6: Math blocks

The concepts

In this work, the positions of the elements, rows, columns, and levels, will count as follows:

Rows, columns, or blocks Levels and Dimensions

1 = Rows, always up and down.2 = Columns, always from left to right3 = Levels, always from top to bottom.4 = Blocks or dimensions, from left to right and top to bottom.

A very important observation:

"The number of rows <= the number of columns."

Were it otherwise, these calculations would be wrong

Page 7: Math blocks

Calculation of positions

Data released:

Block data unit:

FU = Number of rows of the block unitCU = Number of columns of the block unitNU = Number of block unit levelsBU = number of identical blocks to the block unit

The data of the position of the item to search:

PF = Position rowPC = Position ColumnPN = Position LevelPB = Number of Block

General formula for calculating the position of the item to search =

((PF - 1) * CU) + PC + ((FU * CU * (NP - 1))) + ((FU * CU * NU) * (PB - 1))

This formula is the result of combining the different levels of calculationof the position of an element, depending on the arrangement of the unit blocks.

Page 8: Math blocks

2D

Using the general formula we can calculate the position of an element ina table or standard 2D

Unit block data Example:FU = 5 CU = 6 S = 1 BU = 1 elements = 5 * 6 * 1 * 1 = 30

Item data to search:PF = 4 PC = 5 PN = 1 PB = 1

Position the element =((PF - 1) * CU) + PC + ((FU * CU * (NP - 1))) + ((FU * CU * NU) * (PB - 1))

((4-1) * 6) + 5 + ((5 * 6 * (1-1))) + ((5 * 6 * 1) * (1-1)) = 23

We can also be calculated as follows:

2D position = ((PF - 1) * CU) + PC

Substituting values for the variables, we obtain also the position in a 2Dsystem:

((4-1) * 6) + 5 = 23

Page 9: Math blocks

3D

Using the general formula we can calculate the position of an element on a level table or 3D

Unit block data Example:FU = 3 CU = 3 NU = 3 BU = 1 Items = 3 * 3 * 3 * 1 = 27

Item data to search:PF = 3 PC = 3 PN = 3 PB = 1

Position the element =((PF - 1) * CU) + PC + ((FU * CU * (NP - 1))) + ((FU * CU * NU) * (PB - 1))

((3-1) * 3) + 3 + ((3 * 3 * (3-1))) + ((3 * 3 * 3) * (1-1)) = 27

We can also calculate the position as follows:

3D = position ((PF - 1) * CU) + PC + ((FU * CU * (NP - 1)))

Replacing the variables by their values, also we get the position in a 3D system:

((3-1) * 3) + 3 + ((3 * 3 * (3-1))) = 27

Page 10: Math blocks

4D

Using the general formula we can calculate the position of an element ina table or level 4D

Unit block data Example:FU = 3 CU = 3 NU = 3 BU = 3 elements = 3 * 3 * 3 * 3 = 81

Item data to search:PF = 2 PC = 2 PN = 2 PB = 3

Position the element =((PF - 1) * CU) + PC + ((FU * CU * (NP - 1))) + ((FU * CU * NU) * (PB - 1))

((2-1) * 3) + 2 + ((3 * 3 * (2-1))) + ((3 * 3 * 3) * (3-1)) = 68

From 3D, we will always use general formula, simply must know the number of blocks we have in the system.

Page 11: Math blocks

5D

Unit block data Example:FU = 3 CU = 3 NU = 3 BU = 9 elements = 3 * 3 * 3 * 9 = 243

Item data to search:PF = 1 PC = 1 PN = 1 PB = 9

Position the element =((PF - 1) * CU) + PC + ((FU * CU * (NP - 1))) + ((FU * CU * NU) * (PB - 1))

((1 - 1) * 3) + 1 + ((3 * 3 * (1 - 1))) + ((3 * 3 * 3) * (9 - 1)) = 217

Page 12: Math blocks

6D

Unit block data Example:FU = 3 CU = 3 NU = 3 BU = 27 elements = 3 * 3 * 3 * 9 = 729

Item data to search:PF = 3 PC = 3 PN = 2 PB = 27

Position the element =((PF - 1) * CU) + PC + ((FU * CU * (NP - 1))) + ((FU * CU * NU) * (PB - 1))

((3-1) * 3) + 3 + ((3 * 3 * (2-1))) + ((3 * 3 * 3) * (27-1)) = 720

Page 13: Math blocks

Round the problem

In this chapter, we turn to the problem, we know the composition (rows, columns, levels) of the block unit and the position of the element.

Now we look for the row, column, and block level indicated where the item is located.

Psudocodes will use to calculate each stage of the process, at the end of all processes, there is a program in Basic, which includes various stages, to calculate the row of the item you seek.

If we make the stages sequentially, we can not calculate the partial data.

Using pseudocode, it is because they are very simple and everyone can play her the way, as simple as possible.

These processes are general, they serve for all cases.

Page 14: Math blocks

We will use this more complex example:

Data we need in this example:

F = Number of rows of the block unit = 3C = Number of columns of the block unit = 3N = Number of unit block levels = 3B = Number of block searchP = Position the item to search = 683

INT = Part entire Mod = Division remainder

Page 15: Math blocks

The block

Here we calculate the block where the search item.

1D calculation rule, by common sense .

2D, the level is = 1.

CALCULATE BLOCK

F = 3C = 3N = 3P = 683If P MOD (F * C * N) <> 0 ThenB = INT (P / (F * C * N)) + 1ElseB = INT (P / (F * C * N))End ifWrite "BLOCK =" BEnd

BLOCK = 26

Comment:By common sense, if the position of the element to find, the divide between the elements of the block unit (F * C * N), we obtain the blocks drive that contains the element to look or in other words the position where the item is located to search.

We note that if the remainder is "0" means that the search positions, is on the last item in a block.

Otherwise, it is in any position other block or unit block (the first), so the ratio we add a "1".

Page 16: Math blocks

Level

CALCULATE LEVELF = 3C = 3N = 3B = 26P = 683Level = INT (P / (F * C)) + 1If P MOD (F * C) = 0 ThenLevel = Level -1ElseLevel = LevelEnd IfK = Level - ((B-1) * N)Write "LEVEL =" KEnd

LEVEL = 1

Comment:A level consists of rows and columns = F * C = Level.If we divide the position we're in, between the number of elements in a level, "P / (F * C)", we get that level we find, however, this calculation would be as if our example was a block of 3F * 3C * 81N, if at all levels ofour system, we subtract the level where we are, "Level - ((B-1) * N)", we get the level of a single block.

Page 17: Math blocks

The column

CALCULATE COLUMNC = 3P = 683If P <C thenCO = PElseCO = P MOD CEnd IfIf P MOD C = 0 ThenCO = CElseCO = COEnd IfWrite "COLUMN =" COEnd

COLUMN = 2

Comment:We see that if the position to seek, is less than the number of columns of the block unit, the position of the spine to look for, is equal to the position where we are.

If P < C then CO = P

The rest of the process is equal to the level.

Page 18: Math blocks

The Row

CALCULATE ROWF = 3C = 3N = 3B = 26P = 683Level = INT (P / (F * C)) + 1If P MOD (F * C) = 0 ThenLevel = Level -1ElseLevel = LevelEnd If

N = Level <<< see comment on the level

F = INT (((P-CO-((F * C) * (N-1))) / C) +1) <<< Formula to calculate the row

Write "ROW =" F

ROW = 3

After this sequence of calculation, we get all the data, the element to look is in:

BLOCK = 26LEVEL = 1COLUMN = 2ROW = 3

Page 19: Math blocks

Epilogue

You keep thinking that math block is child's play?

Which you find applications to these formulas?

Possible applications:Informatics, Robotics, 3D Automated Storage, Cryptography, 3D Graphics integers.

In computing, it is shown that all vector / Dim 2D, 3D, 4D ..., can be converted into a Vector / Dim 1D.

3D storage, knowing the number of rows, columns and store levels, yousimply need to indicate the position and the program breaks down in row number, column number and level number where the object is to find.

3D graphics, may indicate a 3D point by a value, for example point 3 * 3 * 3, its position is 27, then decompose and get X, Y, Z (Row, Column, Level).

In cryptography and coding coordinates, etc, etc.

For more information and to see the beginning of this work:

http://www.freebasic.net/forum/viewtopic.php?f=3&t=19820

Repository:

http://es.slideshare.net/ZkrouhnZyx/matematicas-con-bloques

To write comments

[email protected]

Dedicated to all people who are curious.

Page 20: Math blocks

Basic programs

Program to calculate the position of the element to find.

:::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::

clsinput "unit block rows ="; roinput "unit block columns ="; coinput "unit levels block ="; itprintinput "Row Position ="; ainput "Column = Position" binput "Position Level =" cinput "block number ="; d

P = ((a - 1) * co) + b + ((ro * co * (c - 1))) + ((* co ro * le) * (d-1))

print "position ="; pend::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Page 21: Math blocks

Program to find the row, column, and block level where there is an element for.

Data required:

Rows of the block unitColumns of the unit blockBlock unit levelsPosition to search

:::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::::::::::::::::::

clsinput "Number of rows of the block unit (rows <= columns) ="; rinput "Number of columns of the block unit (columns> = rows) =" cinput "Number of levels block unit ="; linput "Position to seek ="; ph = l

'Calculating blockif p mod (r * c * l) <> 0 thend = int (p / (r * c * l)) + 1elsed = int (p / (r * c * l))end if

'Calculated levell = int (p / (r * c)) + 1if p mod (r * c) = 0 then l = l-1

'Calculated columnif p <c then a co = pif p> = c then a co = p mod cif mod p c = 0 then co = c

'Calculate rowf = ((p-co - ((r * c) * (l-1))) / c) +1':::::::::::::::::::::::::::::::::

printcolor 12print "blo =" d, "fil =" f; "Col ="; co; "Lev ="; l - ((d-1) * h)end

Page 22: Math blocks

END