Hi,
ich habe folgendes Problem:
Ich brauche die Berechnung der Drehung eines Würfels in X-, Y-, Z-Achse.
Dabei gilt folgendes: Jeder Seite des Würfels ist eine Zahl zugeordnet.
Oben: 0
Vorne: 1
Rechts: 2
Hinten: 3
Links: 4
Unten: 5.
Nun werden in einem Array die Daten des gedrehten Würfels übergeben, d.h ein ungedrehter Würfer hätte bei $drehung[0] = 0, $drehung[1] = 1, $drehung[2] = 2, drehung[3] = 3 usw...
Nun kann aber auch der Array so aussehen z.B.
$drehung[0] = 4
$drehung[1] = 1
$drehung[2] = 0
$drehung[3] = 3
$drehung[4] = 5
$drehung[5] = 2
[Blockierte Grafik: http://media.evo-x.de/media/xna//Teil07a/01_3D-Wuerfel.png]
Das würde heißen, das bei dem GEDREHTEN Würfel 4 = das ursprüngliche LINKS nun OBEN ist, Vorne Vorne bleibt, 0 = das ursprungliche OBEN nun RECHTS ist, hinten hinten bleibt, usw usw..
Im Endeffekt würde rauskommen, dass der Würfel um 90° auf der X-Achse gedreht wurde!
Von der Logistik sehr schwierig vorzustellen...
Nun brauche ich eine Funktion, welche aus dem Array $drehung konkret X-, Y-, Z-Achsendrehung berechnet, damit ein ungedrehter Würfel richtig gedreht wird..
Hoffe ihr versteht mein Problem
.
Habe auch schonmal versucht, das umzusetzen, wo mit aber klar ist, dass es so letztendlich nicht funktionieren kann.
Spoiler anzeigen
Local $end[7], $act[7], $temp[7], $drehung1, $drehung2, $drehung3, $z
$drehung1 = 0
$drehung2 = 0
$drehung3 = 0
$end[1] = 4
$end[2] = 1
$end[3] = 0
$end[4] = 4
$end[5] = 5
$end[6] = 2
for $z = 1 to 6
$act[$z] = $z-1
Next
if ($end[5] = $act[2] and $end[1] = $act[6]) or ($end[5] = $act[1] and $end[1] = $act[5]) or ($end[5] = $act[6] and $end[1] = $act[2]) or ($end[5] = $act[5] and $end[1] = $act[1]) Then
For $y = 0 to 3
if ($end[5] = $act[5] and $end[1] = $act[1]) And ($end[6] = $act[6] and $end[2] = $act[2]) Then
$drehung3 = $y*90
ExitLoop
EndIf
$temp[1] = $act[1]
$temp[2] = $act[2]
$temp[5] = $act[5]
$temp[6] = $act[6]
$act[1] = $temp[6]
$act[2] = $temp[1]
$act[5] = $temp[2]
$act[6] = $temp[5]
Next
For $y = 0 to 3
if ($end[3] = $act[3] And $end[4] = $act[4]) And ($end[2] = $act[2] And $end[6] = $act[6]) Then
$drehung1 = $y*90
ExitLoop
EndIf
$temp[2] = $act[2]
$temp[3] = $act[3]
$temp[4] = $act[4]
$temp[6] = $act[6]
$act[3] = $temp[6]
$act[2] = $temp[3]
$act[4] = $temp[2]
$act[6] = $temp[4]
Next
Elseif ($end[5] = $act[3]) And ($end[1] = $act[4]) Then
For $y = 1 to 3
$temp[1] = $act[1]
$temp[3] = $act[3]
$temp[4] = $act[4]
$temp[5] = $act[5]
$act[1] = $temp[3]
$act[3] = $temp[5]
$act[4] = $temp[1]
$act[5] = $temp[4]
$drehung2 = $y*90
Next
For $y = 0 to 3
if ($end[3] = $act[3] And $end[4] = $act[4]) And ($end[2] = $act[2] And $end[6] = $act[6]) Then
$drehung1 = $y*90
ExitLoop
EndIf
$temp[2] = $act[2]
$temp[3] = $act[3]
$temp[4] = $act[4]
$temp[6] = $act[6]
$act[3] = $temp[6]
$act[2] = $temp[3]
$act[4] = $temp[2]
$act[6] = $temp[4]
Next
Elseif ($end[5] = $act[4]) and ($end[1] = $act[3]) Then
$temp[1] = $act[1]
$temp[3] = $act[3]
$temp[4] = $act[4]
$temp[5] = $act[5]
$act[1] = $temp[3]
$act[3] = $temp[5]
$act[4] = $temp[1]
$act[5] = $temp[4]
$drehung2 = 90
For $y = 0 to 3
if ($end[3] = $act[3] And $end[4] = $act[4]) And ($end[2] = $act[2] And $end[6] = $act[6]) Then
$drehung1 = $y*90
ExitLoop
EndIf
$temp[2] = $act[2]
$temp[3] = $act[3]
$temp[4] = $act[4]
$temp[6] = $act[6]
$act[3] = $temp[6]
$act[2] = $temp[3]
$act[4] = $temp[2]
$act[6] = $temp[4]
Next
EndIf
MsgBox(0, "Ausgabe", "Die Drehungen des Würfels: X: "&$drehung1&" Y: "&$drehung2&" Z: "&$drehung3)
Schonmal Danke für Ideen oder Lösungsansätze!
MfG, Fresapore