Die wunderbare Welt der Schwerkraft von ???
hier eine kleine simulation der gravitationswechselwirkung zwischen mehreren massepunkten (natürlich stark vereinfacht und nicht unbedingt fehlerfrei):

[code:1:4f6dd6bfad]
Graphics 1024,768,16,1
SetBuffer BackBuffer()

Const n = 3 ;anzahl der massepunkte (tatsächlich n+1, da das array bei null anfängt)
Const g# = 6.67259 * 10^(-11) ;gravitationskonstante
Global k#

Type obj
Field m#
Field x#
Field y#
Field v_Fx#
Field v_Fy#
Field vx0#
Field vy0#
End Type

Dim list.obj(n) ; objektliste
Dim v_Ft#(1) ; vektor teilkraft

For i = 0 To n ;initialisierung der liste
list.obj(i) = New obj
Next
Global rg#
Global t0=MilliSecs()
Global t#

Function calc_force(i)
rg#=0
For a = (i+1) To n
r# = Sqr#((list(a)x# - list(i)x#)^2 + (list(a)y# - list(i)y#)^2)
;rg#=rg#+r#
vrx# = list(a)x# - list(i)x# ;richtungsvektor der kraftwirkung
vry# = list(a)y# - list(i)y#

tmp# = (list(a)m# * list(i)m#) / (r#^3) * g#
v_Ft#(0) = tmp# * vrx#
v_Ft#(1) = tmp# * vry#

; Text 1,1,"t="
;Text 50,1,t#;MilliSecs()-t0

list(i)v_Fx# = list(i)v_Fx# + v_Ft#(0)
list(i)v_Fy# = list(i)v_Fy# + v_Ft#(1)

list(a)v_Fx# = list(a)v_Fx# - v_Ft#(0)
list(a)v_Fy# = list(a)v_Fy# - v_Ft#(1)
Next
Return 0
End Function


list(0)m# = 4 * 10^13
list(0)x# = 256
list(0)y# = 192
list(0)vx0# = 0
list(0)vy0# = 0

list(1)m# = 4*10^6
list(1)x# = 256
list(1)y# = 170
list(1)vx0# = 6
list(1)vy0# = 0



list(2)m# = 4 * 10^6
list(2)x# = 256
list(2)y# = 150
list(2)vx0# = 7
list(2)vy0# = 0



list(3)m# = 4 * 10^4
list(3)x# = 256
list(3)y# = 130
list(3)vx0# = 7
list(3)vy0# = 0


time=MilliSecs()
Color 5,5,255
Repeat
If (MilliSecs() - time) >= 10 Then
dif# = (MilliSecs() - time)
k# = 0.05;dif# / 1000
t#=t#+k#
time=MilliSecs()
End If
For i = 0 To n-1
calc_force(i)
v_ax# = list(i)v_Fx# / list(i) m#
v_ay# = list(i)v_Fy# / list(i) m#
list(i)vx0# = list(i)vx0# + v_ax# * k#
list(i)vy0# = list(i)vy0# + v_ay# * k#
list(i)x# = list(i)x# + list(i)vx0# * k#
list(i)y# = list(i)y# + list(i)vy0# * k#
list(i)v_Fx#=0
list(i)v_Fy#=0
If list(i)x# > 800 Then list(i)x#=0
If list(i)x# < 0 Then list(i)x#=800
If list(i)y# > 600 Then list(i)y#=0
If list(i)y# < 0 Then list(i)y#=600

Color 0,0,255

Oval Int(list(i)x#*2-2.5), Int(list(i)y#*2-2.5), 5,5,1
Color 255,255,0
Plot Int(list(i)x#*2), Int(list(i)y#*2)


Next

;rgg#=rg#/n
;If MouseDown(1) Then Color 255,0,0 Else Color 255,255,255
;Plot xc#, rgg#+st
;If xc#>=1024 Then
; st=st+40
; xc#=0
; Color 0,0,200
;Line 0,st,1024,st
; Color 255,255,0
;End If
;xc#=xc#+0.01
Color 255,255,0
v_ax# = list(n)v_Fx# / list(n) m#
v_ay# = list(n)v_Fy# / list(n) m#
list(n)vx0# = list(n)vx0# + v_ax# * k#
list(n)vy0# = list(n)vy0# + v_ay# * k#

list(n)x# = list(n)x# + list(n)vx0# * k#
list(n)y# = list(n)y# + list(n)vy0# * k#
list(n)v_Fx#=0
list(n)v_Fy#=0
; If list(n)x# > 800 Then list(n)x#=0
; If list(n)x# < 0 Then list(n)x#=800
; If list(n)y# > 600 Then list(n)y#=0
; If list(n)y# < 0 Then list(n)y#=600
Color 0,0,255
Oval Int(list(n)x#*2-2.5), Int(list(n)y#*2-2.5),5,5,1
Color 255,255,0
Plot Int(list(n)x#*2), Int(list(n)y#*2)


Flip()
Cls
Until KeyHit(1)
[/code:1:4f6dd6bfad]

wenn jemand was verbessern will, kann er den geänderten code hier posten.
===
von ???
Sieht gut aus, aber man sollte irgendwie mit dem Prog interagieren können.zB neue Massepunkte setzen.

Ps:Wozu gibts den Code-Tag im Forum
Ps2:Was für ein Nick :wink:
===
von ???
Hey, sieht echt herzlich aus :)
===
von ???
Nicht schlecht...und was für ein Nick
===
von ???
THC eben :wink:
===
von ???
Jaja...keine Macht den Drogen... :wink:
===
hm von ???
[quote:212bdc6f61="Apocalyptic"]Jaja...keine Macht den Drogen... :wink:[/quote:212bdc6f61]
man sollte zumindest nicht breit programmieren... ;-)
===
von ???
Hi,
?

Toni
===
Re: hm von ???
[quote:f394ba712f="Tetrahydrocannabinol"][quote:f394ba712f="Apocalyptic"]Jaja...keine Macht den Drogen... :wink:[/quote:f394ba712f]
man sollte zumindest nicht breit programmieren... ;-)[/quote:f394ba712f]
:mrgreen:
===
Re: hm von ???
[quote:e0840f1336="ShadowTurtle"][quote:e0840f1336="Tetrahydrocannabinol"][quote:e0840f1336="Apocalyptic"]Jaja...keine Macht den Drogen... :wink:[/quote:e0840f1336]
man sollte zumindest nicht breit programmieren... ;-)[/quote:e0840f1336]
:mrgreen:[/quote:e0840f1336]
Witzig oder was? :roll: 8)
===
von ???
ich möchte euch nur auf die Forensatzung aufmerksam machen...
keine Unnötigen Diskusionen (obwohl, das ist keine Diskusion, das ist Spam) im CodeArchiv...
===
von ???
Triton, der Gesetzeshüter.

[img:1d7fdba718]http://www.blitzforum.de/images/avatars/d955333f3d94af3bd9774.gif[/img:1d7fdba718]

"Hey Jungs. Macht ihr Stress oder was ?

:wink:



Suche:
(unterstützt mySQL Wildcards ala %)
Titel:
Text:
Autor: