minib3d Drehmatrix

Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Neue Antwort erstellen

Silver_Knee

Betreff: minib3d Drehmatrix

BeitragDo, März 31, 2011 10:33
Antworten mit Zitat
Benutzer-Profile anzeigen
Hey bin grade Dabei die Berechnung der Drehung in Minib3d zu verstehen. Habe mir aus den Unoptimized-Teilen die 3 Drehmatrizen für Pitch, Yaw und Roll geholt und auf Papier den Vektor (0,0,1) in der, von minib3d verwendeten, Reihenfolge, Yaw, Pitch, Roll, mit diesen multipliziert. Heraus kam:

Code: [AUSKLAPPEN]
   sinp:Float=Sin(pit)
   siny:Float=Sin(yaw)
   sinr:Float=Sin(rol)
   
   cosp:Float=Cos(pit)
   cosy:Float=Cos(yaw)
   cosr:Float=Cos(rol)
   
   xt:Float=cosr*siny+sinp*sinr*cosy
   yt:Float=siny-cosy*sinp*cosr
   zt:Float=cosy*cosp


dann habe ich mit folgendem Programm das Praktisch ausgetestet.

Code: [AUSKLAPPEN]
Import "minib3d.bmx"

Graphics3D 800,600,32,2

pivot=CreatePivot()

Local pit:Float=0,yaw:Float=0,rol:Float=0

For pit=0 To 90 Step 90
For yaw=0 To 90 Step 90
For rol=0 To 90 Step 90
   Print "pyr:"+Int(pit)+" "+Int(yaw)+" "+Int(rol)
   positionentity pivot,0,0,0
   RotateEntity pivot,pit,yaw,rol
   
   moveentity pivot,0,0,1
   
   Print ",".join([String(Int((entityx(pivot)))),String(Int(entityy(pivot))),String(Int(entityz(pivot)))])
   
   sinp:Float=Sin(pit)
   siny:Float=Sin(yaw)
   sinr:Float=Sin(rol)
   
   cosp:Float=Cos(pit)
   cosy:Float=Cos(yaw)
   cosr:Float=Cos(rol)
   
   xt:Float=cosr*siny+sinp*sinr*cosy
   yt:Float=sinr*siny-cosy*sinp*cosr
   zt:Float=cosy*cosp
   
   Print ",".join([String(Int(xt)),String(Int(yt)),String(Int(zt))])
Next
Next
Next


Das gab mir heraus:

Code: [AUSKLAPPEN]
pyr:0 0 0
0,0,1
0,0,1
pyr:0 0 90
0,0,1
0,0,1
pyr:0 90 0
-1,0,0
1,0,0
pyr:0 90 90
-1,0,0
0,1,0
pyr:90 0 0
0,-1,0
0,-1,0
pyr:90 0 90
0,-1,0
1,0,0
pyr:90 90 0
0,-1,0
1,0,0
pyr:90 90 90
0,-1,0
0,1,0


Wie es aussieht ist die z-Koordinate richtig, aber bei dem Rest bin ich überfragt. Ich habs schon öfter nachgerechnet, aber die Formeln sollten stimmen.

Hat von euch einer eine Idee, wo mein Fehler liegt

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group