Posts: 5
Threads: 2
Joined: Jan 2023
Reputation:
0
Môže nám niekto pomôcť.
Mám problém s jedným algoritmom. Neviem to vyriešiť.
Ide o triedenie čísel od najväčšieho po najmenšie.
Predmet - Objekt - Strana - súradnice
- súradnice
- súradnice
- súradnice
- súradnice
- súradnice
Predmet - Objekt - Strana - súradnice
- súradnice
- súradnice
Objekt - Strana - súradnice
- súradnice
- súradnice
- súradnice
- súradnice
- súradnice
Objekt - Strana - súradnice
- súradnice
- súradnice
- súradnice
- súradnice
- súradnice
Predmet - Objekt - Strana - súradnice
- súradnice
- súradnice
Strana - súradnice
- súradnice
- súradnice
Strana - súradnice
- súradnice
- súradnice
Strana - súradnice
- súradnice
- súradnice
Predmet - Objekt - Strana - súradnice
- súradnice
- súradnice
- súradnice
- súradnice
- súradnice
Každý predmet má niekoľko objektov.
Každý objekt má niekoľko strán
Každá strana má niekoľko súradníc.
Čo sa môže zmeniť.
Musím ich vytriediť.
Vk = náhodné číslo
Objekt(1, 1, 1, 0).z = Vk
Objekt(1, 1, 1, 1).x = -Vk
Objekt(1, 1, 1, 1).y = -Vk
Objekt(1, 1, 4, 4).x = Vk
Objekt(1, 1, 4, 4).y = -Vk
Objekt(1, 1, 4, 4).z = Vk
Objekt(2, 1, 2, 6).x = Vk
Objekt(2, 1, 2, 6).y = Vk
Objekt(2, 1, 2, 6).z = Vk
Objekt ( 2 , 1 , 2 , 6 )
Predmet - Objekt - Strana - súradnice
Počítal som súradnice a spočítal steny na obejct.
Teraz mám Predmet a Objekt
Skúsil som toto a nefunguje to veľmi dobre:
SwapStran(i, a, b).z = SwapStran(i, a, b).z + Z
SwapObjektov(i, a).z = SwapObjektov(i, a).z + SwapStran(i, a, b).z
--
SwapSubjektov(i).z = SwapSubjektov(i).z + SwapObjektov(i, a).z
toto už nie je možné
pretože súčet rôznych predmetov je príliš veľký a nefunguje to
--
SwapingStran:
Pre i = 1 Do PocetSubjektov
Ak PovolenieSwapObjektov(i) = 1 Potom
Znovu = 0
Pre a = 1 To Subjekt(i).PocetObjektov
Pre b = 1 To Subjekt(i).PocetStran
k = 1: Ak b = Predmet(i).PocetStran Potom k = 0
Ak SwapStran(i, a, b).z > SwapStran(i, a, b + k).z Potom
Swap SwapStran(i, a, b).z, SwapStran(i, a, b + k).z
Znovu = 1
Koniec Ak
Ďalej b
Ďalej a
Ak Znovu = 1, potom prejdite na SwapingStran:
Koniec Ak
Ďalej i
SwapingObjektov:
Pre i = 1 Do PocetSubjektov
Ak PovolenieSwapObjektov(i) = 1 Potom
Znovu = 0: O = 0: Ak i = PocetSubjektov Potom O = 1
Pre a = 1 To Subjekt(i).PocetObjektov
k = 1: Ak a = Subjekt(i).PocetObjektov Potom k = 0
Ak SwapObjektov(i - O, a).z < SwapObjektov(i, a + k).z Potom
Swap SwapObjektov(i - O, a).z, SwapObjektov(i, a + k).z
Znovu = 1
Koniec Ak
Ďalej a
Koniec Ak
Ďalej i
If Znovu = 1 Then GoTo SwapingObjektov
-------------------------------------------------- -------------------------------------
Tu je problém:
Výmena Subjektov:
Znovu = 0: ii = 0: a1 = 1: a = 0
Pre i = 1 Do PocetSubjektov
ii = ii + 1
Ak i + ii >= PocetSubjektov Potom ii = 0: Znovu = 0
Ak PovolenieSwapObjektov(i) = 1 alebo PovolenieSwapObjektov(i + ii) = 1 Potom
Do
a = a + 1
Ak SwapObjektov(i, a).z < SwapObjektov(i + ii, a1).z Potom
Swap SwapObjektov(i, a).z, SwapObjektov(i + ii, a1).z
Znovu = 1
Koniec Ak
Ak a >= Predmet(i).PocetObjektov Potom
a = 0
a1 = a1 + 1
Koniec Ak
Ak a1 >= Subjekt(i + ii).PocetObjektov Then a1 = 1: Exit Do
Slučka, kým znovu = 1
Koniec Ak
Ďalej i
If Znovu = 1 Then GoTo SwapingSubjektov
Posts: 1,510
Threads: 53
Joined: Jul 2022
Reputation:
47
Hi slymer
Is it possible for you to redo this post in English? A very small amount was actually translated in source code. Otherwise I could try to paste this into the QB64 IDE changing "Koniec Ak" into "END IF" for example but it would be laborious. What do you want to do with "SWAP" command?
Posts: 224
Threads: 7
Joined: Apr 2022
Reputation:
14
(03-05-2023, 05:06 PM)CSslymer Wrote: Každý predmet má niekoľko objektov.
Každý objekt má niekoľko strán
Každá strana má niekoľko súradníc.
Čo sa môže zmeniť.
Musím ich vytriediť.
Vk = náhodné číslo
Objekt(1, 1, 1, 0).z = Vk
Objekt(1, 1, 1, 1).x = -Vk
Objekt(1, 1, 1, 1).y = -Vk
Objekt(1, 1, 4, 4).x = Vk
Objekt(1, 1, 4, 4).y = -Vk
Objekt(1, 1, 4, 4).z = Vk
Objekt(2, 1, 2, 6).x = Vk
Objekt(2, 1, 2, 6).y = Vk
Objekt(2, 1, 2, 6).z = Vk
Objekt ( 2 , 1 , 2 , 6 )
Predmet - Objekt - Strana - súradnice
Počítal som súradnice a spočítal steny na obejct.
Teraz mám Predmet a Objekt
Skúsil som toto a nefunguje to veľmi dobre:
SwapStran(i, a, b).z = SwapStran(i, a, b).z + Z
SwapObjektov(i, a).z = SwapObjektov(i, a).z + SwapStran(i, a, b).z
--
SwapSubjektov(i).z = SwapSubjektov(i).z + SwapObjektov(i, a).z
toto už nie je možné
pretože súčet rôznych predmetov je príliš veľký a nefunguje to
--
SwapingStran:
Pre i = 1 Do PocetSubjektov
Ak PovolenieSwapObjektov(i) = 1 Potom
Znovu = 0
Pre a = 1 To Subjekt(i).PocetObjektov
Pre b = 1 To Subjekt(i).PocetStran
k = 1: Ak b = Predmet(i).PocetStran Potom k = 0
Ak SwapStran(i, a, b).z > SwapStran(i, a, b + k).z Potom
Swap SwapStran(i, a, b).z, SwapStran(i, a, b + k).z
Znovu = 1
Koniec Ak
Ďalej b
Ďalej a
Ak Znovu = 1, potom prejdite na SwapingStran:
Koniec Ak
Ďalej i
SwapingObjektov:
Pre i = 1 Do PocetSubjektov
Ak PovolenieSwapObjektov(i) = 1 Potom
Znovu = 0: O = 0: Ak i = PocetSubjektov Potom O = 1
Pre a = 1 To Subjekt(i).PocetObjektov
k = 1: Ak a = Subjekt(i).PocetObjektov Potom k = 0
Ak SwapObjektov(i - O, a).z < SwapObjektov(i, a + k).z Potom
Swap SwapObjektov(i - O, a).z, SwapObjektov(i, a + k).z
Znovu = 1
Koniec Ak
Ďalej a
Koniec Ak
Ďalej i
If Znovu = 1 Then GoTo SwapingObjektov
-------------------------------------------------- -------------------------------------
Tu je problém:
Výmena Subjektov:
Znovu = 0: ii = 0: a1 = 1: a = 0
Pre i = 1 Do PocetSubjektov
ii = ii + 1
Ak i + ii >= PocetSubjektov Potom ii = 0: Znovu = 0
Ak PovolenieSwapObjektov(i) = 1 alebo PovolenieSwapObjektov(i + ii) = 1 Potom
Do
a = a + 1
Ak SwapObjektov(i, a).z < SwapObjektov(i + ii, a1).z Potom
Swap SwapObjektov(i, a).z, SwapObjektov(i + ii, a1).z
Znovu = 1
Koniec Ak
Ak a >= Predmet(i).PocetObjektov Potom
a = 0
a1 = a1 + 1
Koniec Ak
Ak a1 >= Subjekt(i + ii).PocetObjektov Then a1 = 1: Exit Do
Slučka, kým znovu = 1
Koniec Ak
Ďalej i
If Znovu = 1 Then GoTo SwapingSubjektov
wow PE has come a long way
Posts: 176
Threads: 36
Joined: May 2022
Reputation:
16
@mnrvovrfc He wants advice on sorting numbers from largest to smallest - in a four-dimensional array.
Posts: 176
Threads: 36
Joined: May 2022
Reputation:
16
03-05-2023, 05:30 PM
(This post was last modified: 03-05-2023, 05:32 PM by Petr.)
Can someone help us.
I have a problem with one algorithm. I can't solve it.
It is about sorting the numbers from largest to smallest.
Subject - Object - Page - coordinates
- coordinates
- coordinates
- coordinates
- coordinates
- coordinates
Subject - Object - Page - coordinates
- coordinates
- coordinates
Object - Page - coordinates
- coordinates
- coordinates
- coordinates
- coordinates
- coordinates
Object - Page - coordinates
- coordinates
- coordinates
- coordinates
- coordinates
- coordinates
Subject - Object - Page - coordinates
- coordinates
- coordinates
Side - coordinates
- coordinates
- coordinates
Side - coordinates
- coordinates
- coordinates
Side - coordinates
- coordinates
- coordinates
Subject - Object - Page - coordinates
- coordinates
- coordinates
- coordinates
- coordinates
- coordinates
Each object has several objects.
Each object has several sides
Each side has several coordinates.
What can change.
I have to sort them out.
Vk = random number
Object(1, 1, 1, 0).z = Vk
Object(1, 1, 1, 1).x = -Vk
Object(1, 1, 1, 1).y = -Vk
Object(1, 1, 4, 4).x = Vk
Object(1, 1, 4, 4).y = -Vk
Object(1, 1, 4, 4).z = Vk
Object(2, 1, 2, 6).x = Vk
Object(2, 1, 2, 6).y = Vk
Object(2, 1, 2, 6).z = Vk
Object ( 2 , 1 , 2 , 6 )
Subject - Object - Page - coordinates
I calculated the coordinates and counted the walls on the perimeter.
Now I have a Subject and an Object
I tried this and it doesn't work very well:
SwapPage(i, a, b).z = SwapPage(i, a, b).z + Z
SwapObjects(i, a).z = SwapObjects(i, a).z + SwapPages(i, a, b).z
--
SwapSubjects(i).z = SwapSubjects(i).z + SwapObjects(i, a).z
this is no longer possible
because the sum of different items is too big and it doesn't work
--
SwappingPage:
For i = 1 To Number of Subjects
If EnableSwapObject(s) = 1 Then
= 0 again
For a = 1 To Subject(s).Number of Objects
For b = 1 To Subject(s). Number of Pages
k = 1: If b = Subject(s).NumberPages Then k = 0
If SwapPage(i, a, b).z > SwapPage(i, a, b + k).z Then
Swap SwapPage(i, a, b).z, SwapPage(i, a, b + k).z
Again = 1
End If
Further b
Further a
If Again = 1, then go to SwappingPage:
End If
Further i
SwappingObjects:
For i = 1 To Number of Subjects
If EnableSwapObject(s) = 1 Then
Again = 0: O = 0: If i = Number of Subjects Then O = 1
For a = 1 To Subject(s).Number of Objects
k = 1: If a = Subject(s).Number of Objects Then k = 0
If SwapObjects(i - O, a).z < SwapObjects(i, a + k).z Then
Swap SwapObjects(i - O, a).z, SwapObjects(i, a + k).z
Again = 1
End If
Further a
End If
Further i
If Again = 1 Then GoTo SwappingObjects
-------------------------------------------------- -------------------------------------
Here's the problem:
Exchange of Subjects:
Again = 0: ii = 0: a1 = 1: a = 0
For i = 1 To Number of Subjects
ii = ii + 1
If i + ii >= Number of Subjects Then ii = 0: Again = 0
If EnableSwapObjects(i) = 1 or EnableSwapObjects(i + ii) = 1 Then
To
a = a + 1
If SwapObjects(i, a).z < SwapObjects(i + ii, a1).z Then
Swap SwapObjects(i, a).z, SwapObjects(i + ii, a1).z
Again = 1
End If
If a >= Object(s).CountObjects Then
a = 0
a1 = a1 + 1
End If
If a1 >= Subject(i + ii).Number of Objects Then a1 = 1: Exit Do
Loop until again = 1
End If
Further i
If Again = 1 Then GoTo SwappingSubjects
Posts: 176
Threads: 36
Joined: May 2022
Reputation:
16
This is the principle of sorting numbers in a one-dimensional array as I use it. There are better procedures, but hopefully this will help.
Code: (Select All) 'vygeneruju nahodna cisla
Dim A(100) As Long
For bb = 0 To 100
Randomize Timer
A(bb) = 32768 * (1 + bb * Rnd)
Next
'udelam druhe prazdne pole stejne velikosti pro vysledky
Dim B(100) As Long
'porovnam to
For komplet = 0 To 100
hodnota = 0
For s = 0 To 100
If A(s) > -1 Then 'pokud tato hodnota jeste nebyla prirazena - prirazene hodnoty nastavuji na -1 abych jednu hodnotu neulozil vicekrat
If hodnota < A(s) Then hodnota = A(s): zaznam = s
End If
Next s
B(komplet) = hodnota
A(zaznam) = -1
Next komplet
'vypis
For v = 0 To 100
Print "zaznam:"; Str$(v); " - "; B(v)
Sleep
Next
Posts: 2,700
Threads: 124
Joined: Apr 2022
Reputation:
134
03-05-2023, 06:43 PM
(This post was last modified: 03-05-2023, 07:06 PM by bplus.)
I'm confused.
Is there 1 value for every (x, y, z) ie v = f(x, y, z) to sort, like a color for every x, y, z in 3D graphic
Or
is there 1 value for every (x, y, z, t) ie v = f(x, y, z, t) to sort? like getting a pixel color in 3D movie at x, y, z and at a point in time as well!
Or something else all together???
Update: Oh it looks as if there is (x, y, z) at end of array inside an array inside an array inside an array, yikes!
What / where is the value we are sorting? This looks too confused to mess with....
b = b + ...
Posts: 1,510
Threads: 53
Joined: Jul 2022
Reputation:
47
03-05-2023, 07:52 PM
(This post was last modified: 03-05-2023, 07:59 PM by mnrvovrfc.)
Three-dimensional pages? But there's also object and subject.
If the four dimensions don't create a really big array, then it might be better to create an array of strings, first storing the (x,y,z) values in serialized form, and then the four dimensions in turn, also in serialized form. Then it becomes easier to sort by the (x,y,z) values. But then the author would have to decide if he/she wants to order by x, y or z.
For example:
Object(1, 2, 3, 4).x = 2
Object(1, 2, 3, 4).y = 3
Object(1, 2, 3, 4).z = 4
could be turned into this:
Code: (Select All) 004z002x003y001002003004
--- === --- ===---===---
| | | | | | |
| | | | | | fourth dimension (least significant)
| | | | | |
| | | | | third dimension
| | | | |
| | | | second dimension
| | | |
| | | first dimension (most significant)
| | |
| | y-field
| |
| x-field
|
z-field
as a string entry. Put the value first then the field's name to make it easier to sort numerically, and keep the field names in the same order throughout. (Actually the field names serve only for documentation.) Of course, if the value required is greater than 999 then add more zeroes to match the length. If negative values are also required then also add plus or minus sign. There could be other variations about ordering the string value, but this is only to sort the contents. Then how to put it back into the four-dimensional array...
I guess figure out the extents for each dimension and walk sequentially through the string array setting the values. (shrugs)
This example would require good string-parsing routines, instead of the mountains of "FOR... NEXT" and "IF... THEN... END IF" revealed in the code of the first post.
This is only for Objects() array. Now I notice SwapPages(), SwapSubjects(), SwapObjects() which would each need its own special treatment.
Posts: 5
Threads: 2
Joined: Jan 2023
Reputation:
0
(03-05-2023, 06:43 PM)bplus Wrote: Som zmätený.
Existuje 1 hodnota pre každé (x, y, z), tj v = f(x, y, z), ktoré sa má zoradiť, ako farba pre každé x, y, z v 3D grafike Alebo existuje 1 hodnota pre každé (
x
, y, z, t) teda v = f(x, y, z, t) triediť? ako získať pixelovú farbu v 3D filme v bodoch x, y, z a tiež v určitom časovom bode!
Alebo nieco ine dokopy???
Aktualizácia: Vyzerá to tak, že na konci poľa vo vnútri poľa vnútri poľa vo vnútri poľa je (x, y, z), fuj!
Aká / kde je hodnota, ktorú triedime? Vyzerá to príliš zmätene na to, aby sme sa s tým pohrali....
ide o vykresľovanie grafiky. ako prvý sa zobrazí
najvzdialenejší objekt s najväčším číslom . a tak ďalej. táto hodnota je z výpočet súradníc jednej strany objektu. potom celý objekt. a porovnáva sa s objektmi v celom systéme.
Posts: 224
Threads: 7
Joined: Apr 2022
Reputation:
14
|