4D - Rasterizer
Übersicht

![]() |
NoobodyBetreff: 4D - Rasterizer |
![]() Antworten mit Zitat ![]() |
---|---|---|
Durch Lektüre des hervorragenden Buchs Poincarés Vermutung wurde mein Interesse an der vierten Dimension geweckt, weswegen ich mich gleich daran machte, meinen 3D - Rasterizer so umzuschreiben, dass er auch für vier Dimensionen funktioniert.
Auch wenn sich ein Mensch die vierte Dimension nicht wirklich vorstellen, geschweige denn verstehen kann, ist sie trotzdem mathematisch formulierbar und mit Matrizenrechnung darstellbar. Was die vierte Dimension nun repräsentiert, ist dabei nicht wichtig (viele vermuten ja die Zeit als vierte Dimension; im Programm wird die vierte Dimension einfach als geometrischer Raum aufgefasst). Das Programm geht so vor, als dass der 4D - Raum zuerst auf einen 3D - Raum projiziert wird und danach von 3D auf 2D. Ein 4D - Objekt hat 4 Koordinaten und 6 verschiedene Rotationswinkel (da es 6 Rotationsebenen in 4D gibt - in 4D rotiert man nämlich nicht um popelige Geraden, sondern um Ebenen ![]() Eine 4D - Szene zu basteln ist leider nicht ganz einfach, da man sich zum einen nicht richtig vorstellen kann, welche Auswirkung nun eine Rotation oder eine Verschiebung nun auf das Objekt hat, und man zum anderen Schwierigkeiten hat, das Resultat auf dem Bildschirm zu interpretieren und man daher nicht richtig sagen kann, ob man nun alles richtig gemacht hat oder nicht. Nichtsdestotrotz macht es Spass, mit den Objekten herumzuspielen und immer wieder einen 'Hää?' - Moment zu haben, weil man einfach nicht versteht, was da auf dem Bildschirm vor sich geht (schade, dass unsere Vorstellungskraft nicht über 3 Dimensionen hinausgeht ![]() Die Beispielszene zeigt zwei verschiedene 4D - Würfel (den sogenannten Hypercube bzw. Tesserakt), die um verschiedene Ebenen rotiert, verschoben und skaliert werden. Zur besseren Übersicht sind unterschiedliche Liniengruppen eingefärbt. Screenshot: ![]() Code: [AUSKLAPPEN] SuperStrict
Const GWIDTH:Int = 800 Const GHEIGHT:Int = 600 Graphics GWIDTH, GHEIGHT, 0 Local Timer:TTimer = CreateTimer( 60 ) Local Cam:TCamera = TCamera.Camera( 45 ) Cam.Move( Vec4( 0, 0, 0, -3 ) ) Cam.Move3D( Vec3( 0, 0, -10 ) ) Local Mesh:TMesh = Cam.AddMesh() Mesh.CreateTesseract() Mesh.Turn( Vec3( 0, 60, 0 ), Vec3( 0, 0, 0 ) ) Local Cube:TMesh = Cam.AddMesh() Cube.CreateTesseract() While Not KeyHit( KEY_ESCAPE ) Cls Local Counter:Int = MilliSecs() Cam.Render( GWIDTH, GHEIGHT ) DrawText MilliSecs() - Counter, 0, 0 Local Angle:Float = ( MilliSecs() Mod 3600 )/10.0 Mesh.Turn( Vec3( 0, 0, 0 ), Vec3( 0, 0, 1 ) ) Cube.Locate( Vec4( Cos( Angle )*3, 3, 5, 2 ) ) Cube.Turn( Vec3( 0, 2, 0 ), Vec3( 0, 0, 1 ) ) Cube.Scale( Vec4( 1, 0.5, 1, Cos( Angle*2 )*0.5 + 0.5 ) ) Flip 0 WaitTimer Timer Wend End Function Vec3:TVector( X:Float, Y:Float, Z:Float ) Return TVector.Vector( X, Y, Z, 0 ) End Function Function Vec4:TVector( X:Float, Y:Float, Z:Float, W:Float ) Return TVector.Vector( X, Y, Z, W ) End Function Type TVector Field X:Float Field Y:Float Field Z:Float Field W:Float Field T:Float Method Add:TVector( B:TVector ) Self.X :+ B.X Self.Y :+ B.Y Self.Z :+ B.Z Self.W :+ B.W Return Self End Method Method Substract:TVector( B:TVector ) Self.X :- B.X Self.Y :- B.Y Self.Z :- B.Z Self.W :- B.W Return Self End Method Method Multiply:TVector( Scalar:Float ) Self.X :* Scalar Self.Y :* Scalar Self.Z :* Scalar Self.W :* Scalar Return Self End Method Method Invert:TVector() Self.X = 1/Self.X Self.Y = 1/Self.Y Self.Z = 1/Self.Z Self.W = 1/Self.W Return Self End Method Method DotProduct:Float( B:TVector ) Return Self.X*B.X + Self.Y*B.Y + Self.Z*B.Z + Self.W*Self.W End Method Method CrossProduct:TVector( B:TVector, C:TVector ) Local D:Float = B.X*C.Y - B.Y*C.X Local E:Float = B.X*C.Z - B.Z*C.X Local F:Float = B.X*C.W - B.W*C.X Local G:Float = B.Y*C.Z - B.Z*C.Y Local H:Float = B.Y*C.W - B.W*C.Y Local I:Float = B.Z*C.W - B.W*C.Z Local NewX:Float = Self.Y*I - Self.Z*H + Self.W*G Local NewY:Float = -Self.X*I + Self.Z*F - Self.W*E Local NewZ:Float = Self.X*H - Self.Y*F + Self.W*D Local NewW:Float = -Self.X*G + Self.Y*E - Self.Z*D Self.X = NewX Self.Y = NewY Self.Z = NewZ Self.W = NewW Return Self End Method Method Copy:TVector() Return TVector.Vector( Self.X, Self.Y, Self.Z, Self.W, Self.T ) End Method Function Vector:TVector( X:Float, Y:Float, Z:Float, W:Float = 0, T:Float = 1 ) Local Vector:TVector = New TVector Vector.X = X Vector.Y = Y Vector.Z = Z Vector.W = W Vector.T = T Return Vector End Function End Type Type TMatrix Field A:Float[ 5, 5 ] Method Copy:TMatrix() Local Matrix:TMatrix = New TMatrix For Local Row:Int = 0 To 4 For Local Column:Int = 0 To 4 Matrix.A[ Row, Column ] = Self.A[ Row, Column ] Next Next Return Matrix End Method Method MatrixMultiply:TMatrix( B:TMatrix ) Local NewA:Float[ 5, 5 ] For Local Row:Int = 0 To 4 For Local Column:Int = 0 To 4 NewA[ Row, Column ] = Self.A[ Row, 0 ]*B.A[ 0, Column ] NewA[ Row, Column ] :+ Self.A[ Row, 1 ]*B.A[ 1, Column ] NewA[ Row, Column ] :+ Self.A[ Row, 2 ]*B.A[ 2, Column ] NewA[ Row, Column ] :+ Self.A[ Row, 3 ]*B.A[ 3, Column ] NewA[ Row, Column ] :+ Self.A[ Row, 4 ]*B.A[ 4, Column ] Next Next Self.A = NewA Return Self End Method Method VectorMultiply:TVector( B:TVector ) Local X:Float = Self.A[ 0, 0 ]*B.X + Self.A[ 0, 1 ]*B.Y + Self.A[ 0, 2 ]*B.Z + Self.A[ 0, 3 ]*B.W + Self.A[ 0, 4 ]*B.T Local Y:Float = Self.A[ 1, 0 ]*B.X + Self.A[ 1, 1 ]*B.Y + Self.A[ 1, 2 ]*B.Z + Self.A[ 1, 3 ]*B.W + Self.A[ 1, 4 ]*B.T Local Z:Float = Self.A[ 2, 0 ]*B.X + Self.A[ 2, 1 ]*B.Y + Self.A[ 2, 2 ]*B.Z + Self.A[ 2, 3 ]*B.W + Self.A[ 2, 4 ]*B.T Local W:Float = Self.A[ 3, 0 ]*B.X + Self.A[ 3, 1 ]*B.Y + Self.A[ 3, 2 ]*B.Z + Self.A[ 3, 3 ]*B.W + Self.A[ 3, 4 ]*B.T Local T:Float = Self.A[ 4, 0 ]*B.X + Self.A[ 4, 1 ]*B.Y + Self.A[ 4, 2 ]*B.Z + Self.A[ 4, 3 ]*B.W + Self.A[ 4, 4 ]*B.T Return TVector.Vector( X, Y, Z, W, T ) End Method Function Identity:TMatrix() Local Matrix:TMatrix = New TMatrix Matrix.A[ 0, 0 ] = 1 Matrix.A[ 1, 1 ] = 1 Matrix.A[ 2, 2 ] = 1 Matrix.A[ 3, 3 ] = 1 Matrix.A[ 4, 4 ] = 1 Return Matrix End Function Function Translation:TMatrix( Vector:TVector ) Local Matrix:TMatrix = TMatrix.Identity() Matrix.A[ 0, 4 ] = Vector.X Matrix.A[ 1, 4 ] = Vector.Y Matrix.A[ 2, 4 ] = Vector.Z Matrix.A[ 3, 4 ] = Vector.W Return Matrix End Function Function Scale:TMatrix( Vector:TVector ) Local Matrix:TMatrix = New TMatrix Matrix.A[ 0, 0 ] = Vector.X Matrix.A[ 1, 1 ] = Vector.Y Matrix.A[ 2, 2 ] = Vector.Z Matrix.A[ 3, 3 ] = Vector.W Matrix.A[ 4, 4 ] = 1 Return Matrix End Function Function RotationXY:TMatrix( Angle:Float ) Local Matrix:TMatrix = TMatrix.Identity() Matrix.A[ 1, 1 ] = Cos( Angle ) Matrix.A[ 1, 2 ] = Sin( Angle ) Matrix.A[ 2, 1 ] = -Sin( Angle ) Matrix.A[ 2, 2 ] = Cos( Angle ) Return Matrix End Function Function RotationYZ:TMatrix( Angle:Float ) Local Matrix:TMatrix = TMatrix.Identity() Matrix.A[ 0, 0 ] = Cos( Angle ) Matrix.A[ 0, 2 ] = Sin( Angle ) Matrix.A[ 2, 0 ] = -Sin( Angle ) Matrix.A[ 2, 2 ] = Cos( Angle ) Return Matrix End Function Function RotationZX:TMatrix( Angle:Float ) Local Matrix:TMatrix = TMatrix.Identity() Matrix.A[ 0, 0 ] = Cos( Angle ) Matrix.A[ 0, 1 ] = Sin( Angle ) Matrix.A[ 1, 0 ] = -Sin( Angle ) Matrix.A[ 1, 1 ] = Cos( Angle ) Return Matrix End Function Function RotationXW:TMatrix( Angle:Float ) Local Matrix:TMatrix = TMatrix.Identity() Matrix.A[ 1, 1 ] = Cos( Angle ) Matrix.A[ 1, 3 ] = Sin( Angle ) Matrix.A[ 3, 1 ] = -Sin( Angle ) Matrix.A[ 3, 3 ] = Cos( Angle ) Return Matrix End Function Function RotationYW:TMatrix( Angle:Float ) Local Matrix:TMatrix = TMatrix.Identity() Matrix.A[ 2, 2 ] = Cos( Angle ) Matrix.A[ 2, 3 ] = Sin( Angle ) Matrix.A[ 3, 2 ] = -Sin( Angle ) Matrix.A[ 3, 3 ] = Cos( Angle ) Return Matrix End Function Function RotationZW:TMatrix( Angle:Float ) Local Matrix:TMatrix = TMatrix.Identity() Matrix.A[ 0, 0 ] = Cos( Angle ) Matrix.A[ 0, 3 ] = Sin( Angle ) Matrix.A[ 3, 0 ] = -Sin( Angle ) Matrix.A[ 3, 3 ] = Cos( Angle ) Return Matrix End Function Function RotationXYZ:TMatrix( Rotation:TVector ) Return TMatrix.RotationZX( Rotation.Z ).MatrixMultiply( RotationYZ( Rotation.Y ).MatrixMultiply( RotationXY( Rotation.X ) ) ) End Function Function RotationZYX:TMatrix( Rotation:TVector ) Return TMatrix.RotationXY( Rotation.X ).MatrixMultiply( RotationYZ( Rotation.Y ).MatrixMultiply( RotationZX( Rotation.Z ) ) ) End Function Function RotationXYZW:TMatrix( Rotation:TVector ) Return TMatrix.RotationZW( Rotation.Z ).MatrixMultiply( RotationYW( Rotation.Y ).MatrixMultiply( RotationXW( Rotation.X ) ) ) End Function Function RotationZYXW:TMatrix( Rotation:TVector ) Return TMatrix.RotationXW( Rotation.X ).MatrixMultiply( RotationYW( Rotation.Y ).MatrixMultiply( RotationZW( Rotation.Z ) ) ) End Function Method DebugDraw( X:Int, Y:Int ) DrawLine X - 5, Y - 6, X - 5, Y + 110 'Hardcoding \o/ DrawLine X - 5, Y - 6, X + 2, Y - 6 DrawLine X - 5, Y + 110, X + 2, Y + 110 Local ColumnWidth:Int For Local Column:Int = 0 To 4 For Local Row:Int = 0 To 4 Local Element:Float = Self.A[ Row, Column ] If Element < 0 Then DrawText Element, X, Y + Row*25 Else DrawText Element, X + TextWidth( "-" ), Y + Row*25 EndIf If TextWidth( Element ) > ColumnWidth Then ColumnWidth = TextWidth( Element ) Next X :+ 20 + ColumnWidth ColumnWidth = 0 Next DrawLine X - 5, Y - 6, X - 5, Y + 110 DrawLine X - 5, Y - 6, X - 12, Y - 6 DrawLine X - 5, Y + 110, X - 12, Y + 110 End Method End Type Type TVertex Extends TVector Field TFormedCoords:TVector Field ProjectedCoords:TVector Method Copy:TVertex() Return TVertex.Vertex( Vec4( Self.X, Self.Y, Self.Z, Self.W ) ) End Method Function Vertex:TVertex( Position:TVector ) Local Vertex:TVertex = New TVertex Vertex.X = Position.X Vertex.Y = Position.Y Vertex.Z = Position.Z Vertex.W = Position.W Vertex.T = 1 Vertex.ProjectedCoords = Vec4( 0, 0, 0, 0 ) Return Vertex End Function End Type Type TSegment Field V1:TVertex Field V2:TVertex Field Color:TVector Function Segment:TSegment( V1:TVertex, V2:TVertex, Color:TVector ) Local Segment:TSegment = New TSegment Segment.V1 = V1 Segment.V2 = V2 Segment.Color = Color Return Segment End Function End Type Type TEntity Field Position:TVector Field Scaling:TVector Field Rotation:TMatrix Field InvRotation:TMatrix Method New() Self.Locate( Vec4( 0, 0, 0, 0 ) ) Self.Rotate( Vec3( 0, 0, 0 ), Vec3( 0, 0, 0 ) ) Self.Scale ( Vec4( 1, 1, 1, 1 ) ) End Method Method Turn( Real:TVector, Imaginary:TVector ) Self.Rotation = TMatrix.RotationXYZ( Real ).MatrixMultiply( TMatrix.RotationXYZW( Imaginary ).MatrixMultiply( Self.Rotation ) ) Self.InvRotation = Self.InvRotation.MatrixMultiply( TMatrix.RotationZYXW( Imaginary.Multiply( -1 ) ).MatrixMultiply( TMatrix.RotationZYX( Real.Multiply( -1 ) ) ) ) End Method Method Move( Vector:TVector ) Self.Position.Add( Vector ) End Method Method Rotate( Real:TVector, Imaginary:TVector ) Self.Rotation = TMatrix.RotationXYZ( Real ).MatrixMultiply( TMatrix.RotationXYZW( Imaginary ) ) Self.InvRotation = TMatrix.RotationZYXW( Imaginary ).MatrixMultiply( TMatrix.RotationZYX( Real.Multiply( -1 ) ) ) End Method Method Locate( Vector:TVector ) Self.Position = Vector End Method Method Scale( Vector:TVector ) Self.Scaling = Vector End Method End Type Type TCamera Extends TEntity Field AOV:Float 'Angle of view Field Meshes:TList Field Position3D:TVector Field Rotation3D:TMatrix Method New() Self.Locate( Vec4( 0, 0, 0, 0 ) ) Self.Rotate( Vec3( 0, 0, 0 ), Vec3( 0, 0, 0 ) ) Self.Scale ( Vec4( 1, 1, 1, 1 ) ) Self.Locate3D( Vec3( 0, 0, 0 ) ) Self.Rotate3D( Vec3( 0, 0, 0 ) ) End Method Method Turn3D( Vector:TVector ) Self.Rotation3D = TMatrix.RotationXYZ( Vector ).MatrixMultiply( Self.Rotation3D ) End Method Method Move3D( Vector:TVector ) Self.Position3D.Add( Vector ) End Method Method Rotate3D( Vector:TVector ) Self.Rotation3D = TMatrix.RotationXYZ( Vector ) End Method Method Locate3D( Vector:TVector ) Self.Position3D = Vector End Method Method AddMesh:TMesh() Local Mesh:TMesh = TMesh.Mesh() Self.Meshes.AddLast( Mesh ) Return Mesh End Method Method Render( ScreenWidth:Int, ScreenHeight:Int ) Local PlaneDist:Float = 1/Tan( Self.AOV/2.0 ) Local TFormMatrix:TMatrix = TMatrix.Translation( Self.Position ).Copy().MatrixMultiply( Self.Rotation.Copy().MatrixMultiply( TMatrix.Scale( Self.Scaling ) ) ) For Local Mesh:TMesh = EachIn Self.Meshes Local InvTFormMat:TMatrix = TMatrix.Translation( Mesh.Position.Copy().Multiply( -1 ) ).MatrixMultiply( Mesh.InvRotation.Copy().MatrixMultiply( TMatrix.Scale( Mesh.Scaling ) ) ) For Local Vertex:TVertex = EachIn Mesh.Vertices Vertex.TFormedCoords = TFormMatrix.VectorMultiply( InvTFormMat.VectorMultiply( Vertex.Copy() ) ) Vertex.ProjectedCoords.X = ( Vertex.TFormedCoords.X*PlaneDist/Vertex.TFormedCoords.W ) Vertex.ProjectedCoords.Y = ( Vertex.TFormedCoords.Y*PlaneDist/Vertex.TFormedCoords.W ) Vertex.ProjectedCoords.Z = ( Vertex.TFormedCoords.Z*PlaneDist/Vertex.TFormedCoords.W ) Next Next TFormMatrix = TMatrix.Translation( Self.Position3D ).Copy().MatrixMultiply( Self.Rotation3D ) For Local Mesh:TMesh = EachIn Self.Meshes For Local Vertex:TVertex = EachIn Mesh.Vertices Vertex.TFormedCoords = TFormMatrix.VectorMultiply( Vertex.ProjectedCoords.Copy() ) Vertex.ProjectedCoords.X = ( Vertex.TFormedCoords.X*PlaneDist/Vertex.TFormedCoords.Z + 1 )*ScreenWidth/2 Vertex.ProjectedCoords.Y = ( Vertex.TFormedCoords.Y*PlaneDist/Vertex.TFormedCoords.Z + ScreenHeight/Float( ScreenWidth ) )*ScreenWidth/2 Next For Local Segment:TSegment = EachIn Mesh.Segments SetColor Segment.Color.X, Segment.Color.Y, Segment.Color.Z DrawLine Segment.V1.ProjectedCoords.X, Segment.V1.ProjectedCoords.Y, Segment.V2.ProjectedCoords.X, Segment.V2.ProjectedCoords.Y Next Next End Method Function Camera:TCamera( AOV:Float = 60 ) Local Cam:TCamera = New TCamera Cam.AOV = AOV Cam.Meshes = New TList Return Cam End Function End Type Type TMesh Extends TEntity Field SegmentColor:TVector = Vec3( 255, 255, 255 ) Field Vertices:TList Field Segments:TList Method AddVertex:TVertex( Position:TVector ) Local Vertex:TVertex = TVertex.Vertex( Position ) Self.Vertices.AddLast( Vertex ) Return Vertex End Method Method AddSegment:TSegment( V1:TVertex, V2:TVertex ) Local Segment:TSegment = TSegment.Segment( V1, V2, Self.SegmentColor ) Self.Segments.AddLast( Segment ) Return Segment End Method Method SetRGB( Color:TVector ) Self.SegmentColor = Color End Method Method CreatePentachoron() Local V1:TVertex = Self.AddVertex( Vec4( 1/Sqr( 10 ), 1/Sqr( 6 ), 1/Sqr( 3 ), 1 ) ) Local V2:TVertex = Self.AddVertex( Vec4( 1/Sqr( 10 ), 1/Sqr( 6 ), 1/Sqr( 3 ), -1 ) ) Local V3:TVertex = Self.AddVertex( Vec4( 1/Sqr( 10 ), 1/Sqr( 6 ), -2/Sqr( 3 ), 0 ) ) Local V4:TVertex = Self.AddVertex( Vec4( 1/Sqr( 10 ), -Sqr( 2/3.0 ), 0, 0 ) ) Local V5:TVertex = Self.AddVertex( Vec4( -2*Sqr( 2/5.0 ), 0, 0, 0 ) ) Self.SetRGB( Vec3( 0, 128, 0 ) ) Self.AddSegment V1, V2 Self.AddSegment V2, V3 Self.AddSegment V3, V1 Self.AddSegment V1, V4 Self.AddSegment V2, V4 Self.AddSegment V3, V4 Self.SetRGB( Vec3( 128, 0, 128 ) ) Self.AddSegment V1, V5 Self.AddSegment V2, V5 Self.AddSegment V3, V5 Self.AddSegment V4, V5 End Method Method CreateTesseract() Local V1:TVertex = Self.AddVertex( Vec4( -1, -1, -1, -1 ) ) Local V2:TVertex = Self.AddVertex( Vec4( -1, -1, 1, -1 ) ) Local V3:TVertex = Self.AddVertex( Vec4( 1, -1, 1, -1 ) ) Local V4:TVertex = Self.AddVertex( Vec4( 1, -1, -1, -1 ) ) Local V5:TVertex = Self.AddVertex( Vec4( -1, 1, -1, -1 ) ) Local V6:TVertex = Self.AddVertex( Vec4( -1, 1, 1, -1 ) ) Local V7:TVertex = Self.AddVertex( Vec4( 1, 1, 1, -1 ) ) Local V8:TVertex = Self.AddVertex( Vec4( 1, 1, -1, -1 ) ) Self.SetRGB( Vec3( 0, 128, 0 ) ) Self.AddSegment V1, V2 Self.AddSegment V2, V3 Self.AddSegment V3, V4 Self.AddSegment V4, V1 Self.AddSegment V5, V6 Self.AddSegment V6, V7 Self.AddSegment V7, V8 Self.AddSegment V8, V5 Self.AddSegment V1, V5 Self.AddSegment V2, V6 Self.AddSegment V3, V7 Self.AddSegment V4, V8 Self.SetRGB( Vec3( 128, 0, 0 ) ) Local V09:TVertex = Self.AddVertex( Vec4( -1, -1, -1, 1 ) ) Local V10:TVertex = Self.AddVertex( Vec4( -1, -1, 1, 1 ) ) Local V11:TVertex = Self.AddVertex( Vec4( 1, -1, 1, 1 ) ) Local V12:TVertex = Self.AddVertex( Vec4( 1, -1, -1, 1 ) ) Local V13:TVertex = Self.AddVertex( Vec4( -1, 1, -1, 1 ) ) Local V14:TVertex = Self.AddVertex( Vec4( -1, 1, 1, 1 ) ) Local V15:TVertex = Self.AddVertex( Vec4( 1, 1, 1, 1 ) ) Local V16:TVertex = Self.AddVertex( Vec4( 1, 1, -1, 1 ) ) Self.AddSegment V09, V10 Self.AddSegment V10, V11 Self.AddSegment V11, V12 Self.AddSegment V12, V09 Self.AddSegment V13, V14 Self.AddSegment V14, V15 Self.AddSegment V15, V16 Self.AddSegment V16, V13 Self.AddSegment V09, V13 Self.AddSegment V10, V14 Self.AddSegment V11, V15 Self.AddSegment V12, V16 Self.SetRGB( Vec3( 128, 0, 128 ) ) Self.AddSegment V1, V09 Self.AddSegment V2, V10 Self.AddSegment V3, V11 Self.AddSegment V4, V12 Self.AddSegment V5, V13 Self.AddSegment V6, V14 Self.AddSegment V7, V15 Self.AddSegment V8, V16 End Method Method CreateSphere() 'Liefert nicht richtige Resultate - ich hab leider keine Ahnung, wie eine 4D - Kugel aussehen soll :( Local Radius:Float = 1 For Local Angle:Float = 0 To 350 Step 10 Local OldVertex1:TVertex = Null Local OldVertex2:TVertex = Null For Local Y:Float = -Radius To Radius + 0.3 Step 0.3 Local SliceRadius:Float = Sqr( Radius*Radius - Y*Y ) If IsNan( SliceRadius ) Then SliceRadius = 0 If Y > Radius Then Y = Radius + 0.01 Else Y = -Radius EndIf Local X:Float = Cos( Angle )*SliceRadius Local Z:Float = Sin( Angle )*SliceRadius Local Vertex1:TVertex = Self.AddVertex( Vec4( X, Y, Z, -Y/Radius + 1 ) ) Local Vertex2:TVertex = Self.AddVertex( Vec4( X, Y, Z, Y/Radius - 1 ) ) If OldVertex1 Then Self.AddSegment OldVertex1, Vertex1 If OldVertex2 Then Self.AddSegment OldVertex2, Vertex2 OldVertex1 = Vertex1 OldVertex2 = Vertex2 Self.AddSegment Vertex1, Vertex2 If Y = -Radius Then Y = Y - 0.1 Next Next End Method Function Mesh:TMesh() Local Mesh:TMesh = New TMesh Mesh.Vertices = New TList Mesh.Segments = New TList Return Mesh End Function End Type |
||
Man is the best computer we can put aboard a spacecraft ... and the only one that can be mass produced with unskilled labor. -- Wernher von Braun |
![]() |
XeresModerator |
![]() Antworten mit Zitat ![]() |
---|---|---|
Aua, mein Gehirn!
Schön an zu sehen. Wer sich interessiert, vor Zeiten gab es mal eine Video Serie dazu... Da haben wir's:9 Kapitel, zwei Stunden Mathematik - bis in die 4. Dimension (auch auf Deutsch). |
||
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus THERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld) |
![]() |
hazumu-kun |
![]() Antworten mit Zitat ![]() |
---|---|---|
In der Tat. Aua mein Gehirn
Ich glaub ich schreib mir das als Screensaver um. Dann werd ich direkt bestraft wenn ich afk bin. |
||
Warum kann es keine omnipotente Macht geben?
Weil diese omnipotente Macht in der Lage sein müsste, einen so schweren Stein zu schaffen, dass sie ihn nicht heben kann -> nicht omnipotent |
![]() |
Lord Stweccys |
![]() Antworten mit Zitat ![]() |
---|---|---|
Felix R. Paturi (vielleicht kennt einer von euch ihn) hat mal ein Programm geschreiben, mit dem sich ein Würfel in ALLEN Dimensionen zeichnen lässt. Müsste mal wieder in meiner CD-Sammlung rumkramen... | ||
![]() |
das wurgel |
![]() Antworten mit Zitat ![]() |
---|---|---|
Moin
Ich würd das echt echt zugern testen, hab aber leider kein bmax. Ich hab aber ein kleines Gedankenexperiment zur 4 Dimension: Ich wisst ja sicher alle was ein Möbilusbanbd ist. Nehmen wir an, unser Raum-Zeit-Kontinoum befände sich auf einem 4 dimensionalen Möblilusband und jemand geht einmal rum, dann müsste er doch seitenverkehrt wieder ankommen, oder? Versteht ihr was ich meine? MfG |
||
1 ist ungefähr 3 |
![]() |
XeresModerator |
![]() Antworten mit Zitat ![]() |
---|---|---|
Lord Stweccys: Alle Dimensionen? Das sind doch unendlich viele?
das wurgel: Worauf soll dieses Seitenverkehrt hinauslaufen? |
||
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus THERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld) |
![]() |
Noobody |
![]() Antworten mit Zitat ![]() |
---|---|---|
das wurgel hat Folgendes geschrieben: Nehmen wir an, unser Raum-Zeit-Kontinoum befände sich auf einem 4 dimensionalen Möblilusband und jemand geht einmal rum, dann müsste er doch seitenverkehrt wieder ankommen, oder?
Das Ding heisst Möbiusband ![]() Ich verstehe nicht ganz, wie du das 'seitenverkehrt' meinst - wenn man auf einem Möbiusband einmal herumläuft, erscheint man am Startpunkt, nur auf 'der anderen Seite'. Jemand, der 'normal herum' am Startpunkt steht, kann von uns nicht wahrgenommen werden und umgekehrt, folglich sieht auch niemand, dass wir 'verkehrt herum' stehen. Desweiteren kann das Universum gar keine Form annehmen kann, die einem 4D - Möbiusband entspricht. Objekte wie Möbiusbänder (oder die Kleinsche Flasche) werden in der Topologie nicht-orientierbare Mannigfaltigkeiten genannt und können nicht auf einen Körper gelegt werden, so dass dieser Volumen enthält - wie auch? Ein Möbiusband bzw. eine Kleinsche Flasche hat ja nur eine Seite, während eine orientierbare Mannigfaltigkeit wie die Oberfläche eines Würfels eine Innen- und eine Aussenseite haben muss (mal ganz salopp gesagt). Daher kann unser Universum gar nicht diese Form haben, da es sonst gar keinen Raum beinhalten könnte (in dem wir aber grade stehen). Ich bezweifle also, dass unser Universum so aussehen kann. Allerdings bin ich kein studierter Mathematiker, was heisst, dass ich auch falsche Schlüsse ziehen kann - daher alle Angaben ohne Gewähr ![]() |
||
Man is the best computer we can put aboard a spacecraft ... and the only one that can be mass produced with unskilled labor. -- Wernher von Braun |
![]() |
das wurgel |
![]() Antworten mit Zitat ![]() |
---|---|---|
Sry wegen der Rechtschreibung, bin etwas müde.
Also ich hab mir das jetzt einfach von einem normalen 3-Dimensionalem Möbiusband abgleitet. Darauf könnte ja ein 2-Dimensionales Wesen existieren, denn es besitzt Breite und Länge. Also müsste es auf einem 4-Dimensionalen Möniusband Höhe, Breite und Tiefe geben. Un woher weist du, dass wenn das 2D-Wesen einmal rumgeht, es nicht auch auf der anderen Seite existiert? Ich gehe davon aus das zwei gegenüberüberliegende Seiten ein und das selbe sind, also wie wenn man mit einer Schere reinschneiden würde. Denn wenn das nicht so wäre würde ein ganz normales Band ja aus zwei von einander getrennten Welten bestehen. |
||
1 ist ungefähr 3 |
![]() |
mahe |
![]() Antworten mit Zitat ![]() |
---|---|---|
Nah, die Welt am Band ist doppelt so lang wie das Band selbst. Einmal 'oben' rum und einmal 'unten' rum. | ||
ʇɹǝıdɯnɹɹoʞ ɹnʇɐuƃıs - ǝpoɥʇǝɯ-ɹoɹɹıɯ ɹǝp uı ,ɹoɹɹǝ, |
![]() |
das wurgel |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ja, aber gleichzeitig müsste sie sich ja noch mit sich selbst überlagern. Weil sonst wäre es ja nichts anderes als ein Band, welches doppelt so groß ist. | ||
1 ist ungefähr 3 |
ke^kx |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Nein müssen sie nicht ![]() Ein Band was doppelt so lang ist, hat ja wieder 2 Seiten... |
||
http://i3u8.blogspot.com
Asus Striker II Intel Core2Quad Q9300 @ 2,5 GHz (aber nur zwei Kerne aktiv aufgrund der Instabilität -.-) Geforce 9800 GTX 2GB RAM |
![]() |
hazumu-kun |
![]() Antworten mit Zitat ![]() |
---|---|---|
Kleiner Verbesserrungsvorschlag.
Bei der Mainloop folgendes hinschreiben: BlitzMax: [AUSKLAPPEN]
Ich hatte 5 minuten auf dem X rumgeklickt bis mir eingefallen ist das da KEY_ESCAPE und nicht AppTermiate() als Abbruchbesdingung steht. |
||
Warum kann es keine omnipotente Macht geben?
Weil diese omnipotente Macht in der Lage sein müsste, einen so schweren Stein zu schaffen, dass sie ihn nicht heben kann -> nicht omnipotent |
![]() |
hazumu-kun |
![]() Antworten mit Zitat ![]() |
---|---|---|
Die Functions mit der 4D Sphere kannst du komplett rausnehmen.
Da eine 4D-Sphere aus undendlich Punkten besteht und Jeder Punkt mit einer Surface gleichzusetzten ist, würde sich das mit keinem Computer der Welt metarealistisch darstellen lassen. |
||
Warum kann es keine omnipotente Macht geben?
Weil diese omnipotente Macht in der Lage sein müsste, einen so schweren Stein zu schaffen, dass sie ihn nicht heben kann -> nicht omnipotent |
FWeinbehemals "ich" |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Soweit ich das jetzt Verstanden habe (habe mir die Vids aus dem ersten Post hier angeschaut) kann man eine 4D Sphere also eine Hypersphere auf auf den 3 Dimensionalen Raum Projizieren:
Wikipedia hat dieses Bild: Zitat: Just as a stereographic projection can project a sphere's surface to a plane, it can also project a 4-sphere's surface into 3-space. This image shows three coordinate directions projected to 3-space: parallels (red), meridians (blue) and hypermeridians (green). Due to the conformal property of the stereographic projection, the curves intersect each other orthogonally (in the yellow points) as in 4D. All of the curves are circles: the curves that intersect <0,0,0,1> have an infinite radius (= straight line). mfg ich |
||
![]() |
ozzi789 |
![]() Antworten mit Zitat ![]() |
---|---|---|
Dürft ich um ne Exe bitten, sieht ziemlich interessant aus! ![]() |
||
0x2B || ! 0x2B
C# | C++13 | Java 7 | PHP 5 |
![]() |
hazumu-kun |
![]() Antworten mit Zitat ![]() |
---|---|---|
Wie meinen?
Du willst den 4D Rasterizer mit nem Beispiel kompiliert haben? |
||
Warum kann es keine omnipotente Macht geben?
Weil diese omnipotente Macht in der Lage sein müsste, einen so schweren Stein zu schaffen, dass sie ihn nicht heben kann -> nicht omnipotent |
![]() |
tft |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hi ...
ich hätte ebenfals intresse. Aber ich habe kein BMax das leuft. Habe vor langer Zeit aufgehört zu verstehen warum. Bitte ne exe. Gruss TFT |
||
TFT
https://www.sourcemagic.ch Monkey,HTML5,CSS3,W 10 64 Bit, 32 GB Ram, GTX Titan, W8 ist Müll !!!!!! |
![]() |
Nicdel |
![]() Antworten mit Zitat ![]() |
---|---|---|
Hier:
https://www.blitzforum.de/upload/file.php?id=6387 |
||
Desktop: Intel Pentium 4 2650 Mhz, 2 GB RAM, ATI Radeon HD 3850 512 MB, Windows XP
Notebook: Intel Core i7 720 QM 1.6 Ghz, 4 GB DDR3 RAM, nVidia 230M GT, Windows 7 |
![]() |
Noobody |
![]() Antworten mit Zitat ![]() |
---|---|---|
viken_emesh hat Folgendes geschrieben: Die Functions mit der 4D Sphere kannst du komplett rausnehmen.
Da eine 4D-Sphere aus undendlich Punkten besteht und Jeder Punkt mit einer Surface gleichzusetzten ist, würde sich das mit keinem Computer der Welt metarealistisch darstellen lassen. Eine 3D - Kugel hat auch eine unendliche Anzahl an Punkten, trotzdem kann man sie mit einer endlichen Anzahl Vertices annähern. Dies ist auch im 4D - Raum nicht anders - ich versuchte in der Funktion, die vierdimensionale Kugel anzunähern (was leider nicht geklappt hat ![]() |
||
Man is the best computer we can put aboard a spacecraft ... and the only one that can be mass produced with unskilled labor. -- Wernher von Braun |
![]() |
faeX |
![]() Antworten mit Zitat ![]() |
---|---|---|
Mal abgesehen davon, dass dieses Thema für meine Synapsen lebensgefährlich ist, hätte ich auch gerne eine exe, der Download ist nicht mehr da ![]() |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group