I would like to create the following world with a WinForms application and a PictureBox: the observer stands in the middle and on the floor of this spherical world. He can turn his view 360°: North - East - South - West - North. He can also look up (from his point of view by max. 90° (zenith), so ϑ = 0°) and look at the horizon (0°, ϑ = 90°). So the observer always sees the ‘inner wall’ of the sphere. That's what I want to draw in the PictureBox.
The first goal is to get the whole thing working and see the world turning. The painted sky should have points so that you can see that there is turning something.
What do I need for this? What do I need to download from NuGet? Here is what I've tried.
FormMain.vb
Imports System.Windows.Media.Media3D
Public NotInheritable Class FormMain
Private Sphere As New Class_Sphere
Private Sub FormMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BackColor = Color.FromArgb(180, 191, 183)
PictureBox1.BackColor = Color.Black
Me.Location = New Point(0, 0)
End Sub
Private Sub FormMain_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
Case Keys.Up
If Sphere.Theta > 0US Then
Sphere.Theta -= 1US
End If
Case Keys.Down
If Sphere.Theta < 90US Then
Sphere.Theta += 1US
End If
Case Keys.Left
If Sphere.Phi < 360US Then
Sphere.Phi += 1US
End If
If Sphere.Phi = 360US Then Sphere.Phi = 0US
Case Keys.Right
If Sphere.Phi > 0US Then
Sphere.Phi -= 1US
End If
Case Else
Exit Select
End Select
Sphere.R_kart = Sphere.R_Polar * Math.Sin(CDbl(Sphere.Theta) * Math.PI / 180.0)
Sphere.x_kart = Sphere.R_kart * Math.Cos(CDbl(Sphere.Phi) * Math.PI / 180.0)
Sphere.y_kart = Sphere.R_kart * Math.Sin(CDbl(Sphere.Phi) * Math.PI / 180.0)
Sphere.z_kart = Sphere.R_Polar * Math.Cos(CDbl(Sphere.Theta) * Math.PI / 180.0)
Sphere.R_Polar_V = New Vector3D(Sphere.x_kart, Sphere.y_kart, Sphere.z_kart)
'Debug.WriteLine("ϑ = " & Sphere.Theta & " 𝜑 = " & Sphere.Phi)
End Sub
Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint
End Sub
Private Sub FormMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
If MessageBox.Show("Wirklich schließen?", "Programm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No Then e.Cancel = True
End Sub
End Class
Class_Sphere.vb
Imports System.Windows.Media.Media3D
Public NotInheritable Class Class_Sphere
''' <summary>
''' Höhenwinkel von 0° (oben) bis 90° (horizontal)
''' </summary>
Public Theta As UInt16 = 90US
''' <summary>
''' Seitenwinkel von 0° bis 360°
''' </summary>
Public Phi As UInt16 = 0US
Public R_Polar As Double = 100.0R
''' <summary>
''' horizontale Entfernung
''' </summary>
Public R_kart As Double = 0R
Public x_kart As Double = 0R
Public y_kart As Double = 0R
Public z_kart As Double = 0R
Public R_Polar_V As Vector3D
Public alle_Punkte As List(Of Vector3D)
End Class
The axis names and variables are taken from the GET Lab
video
from Recent Questions - Stack Overflow https://ift.tt/3tNRbw0
https://ift.tt/3dJb3ea
No comments:
Post a Comment