English
Source / code snippets

Dreikörperproblem Nprocs planets sun Sonnensystem

 

Nico
Madysa
Simulation one Sternensystems. is The volume of/ one sun same zero, so becomes one planets-Sonnensystem viewing, otherwise one Doppelstern with planet's. The Sonnenradius must not zero his. program with XPSE and nativen functions.
CompileMarkSeparation
 {$cleq}

{Gravi

    nproc Gravi

        parameters gamma!,x1!,y1!,m1!,x2!,y2!,m2!
        var r2! = sqr(x1! - x2!) + sqr(y1! - y2!)
        case nnull(r2!) : return 0
        return gamma! * m1! * m2! / r2! 0.0000000000667428 * m1! * m2! / r2!

    endproc

    {nnull

        nproc nnull

            parameters x!
            case (fabs(x!) < 0.000001) : return 1
            return 0

        endproc

        {nnnull

            nproc nnnul

                parameters x!
                case (fabs(x!) < 0.000001) : return 0
                return 1

            endproc

            {fabs

                nproc fabs

                    parameters x!
                    case (x! < 0.0) : return (-1.0) * x!
                    return x!

                endproc

                {fif

                    nproc fif

                        parameters bed&, fthen!, felse!
                        case bed& : return fthen!
                        return felse!

                    endproc

                    {arctan

                        nproc arctan

                            parameters atan!
                            return (atan! + 0.43157974 * atan!*sqr(atan!)) / (1.0 + 0.76443945 * sqr(atan!) + 0.05831938 * sqr(sqr(atan!)))

                        }endproc

                        {arccos

                            nproc arccos

                                parameters acos!
                                case acos! = 1 : return 0
                                case acos! = -1 : return Pi()
                                return (Pi() / 2) - arctan(acos! / Sqrt(1 - Sqr(acos!)))

                            }endproc

                            {GetAngle

                                nproc GetAngle

                                    parameters dx!,dy!
                                    case (dx! * dy!) < 0.0000001 : return 0
                                    case dy! <= 0 : return arccos(dx! / Sqrt(Sqr(dx!) + Sqr(dy!)))
                                    return 2 * Pi() - arccos(dx! / Sqrt(Sqr(dx!) + Sqr(dy!)))

                                }endproc

                                {UseBrush

                                    nproc useBrush

                                        parameters t&,c&

                                        if t&=0

                                            SelectObject(memDC,GetStockObject(NULL_BRUSH))

                                        elseif t&=1

                                            SetDCBrushColor(memDC,c&)
                                            SelectObject(memDC,GetStockObject(DC_BRUSH))

                                        endif

                                    endproc

                                    {usePen

                                        nproc usePen

                                            parameters t&,w&,c&

                                            if t&=5

                                                SelectObject(memDC,GetStockObject(NULL_PEN))

                                            elseif t&=0

                                                SetDCPenColor(memDC,c&)
                                                SelectObject(memDC,GetStockObject(DC_PEN))

                                            endif

                                        endproc

                                        {Mal_es

                                            nproc Mal_Es

                                                parameters x1!,y1!,x2!,y2!,x3!,y3!
                                                Luusch
                                                UseBrush(1,$FFFFFF)
                                                UsePen(5,0,0)
                                                Rectangle(&memDC,0,0,640,480)
                                                Körper
                                                UseBrush(1,$FF)
                                                Ellipse(&memDC,int(x1!)-10,int(y1!)-10,int(x1!)+10,int(y1!)+10)
                                                Ellipse(&memDC,int(x2!)-10,int(y2!)-10,int(x2!)+10,int(y2!)+10)
                                                UseBrush(1,0)
                                                Ellipse(&memDC,int(x3!)- 5,int(y3!)- 5,int(x3!)+ 5,int(y3!)+ 5)
                                                BitBlt(%hDC,0,0,640,480,&memDC,0,0,SRCCOPY)

                                            endproc

                                            {main

                                                nproc main

                                                    parameters mx!,my!,gamma!,r1!,r2!,m1!,m2!,m3!,v1!,v3!
                                                    declare F12!,F13!,F23!,r12!,r13!,r23!
                                                    var s1_x!  = mx! + r1!
                                                    var s1_y!  = my!
                                                    var s1_m!  = m1!
                                                    var s1_vx! = 0.0
                                                    var s1_vy! = 0.0 - v1!
                                                    var s2_x!  = mx! - r1!
                                                    var s2_y!  = my!
                                                    var s2_m!  = m2!
                                                    var s2_vx! = 0.0
                                                    var s2_vy! = v1!
                                                    var s3_x!  = mx! + r2!
                                                    var s3_y!  = my!
                                                    var s3_m!  = m3!
                                                    var s3_vx! = 0.0
                                                    var s3_vy! = 0.0 - v3!
                                                    Mal_es(s1_x!,s1_y!,s2_x!,s2_y!,s3_x!,s3_y!)
                                                    Sleep(1000)

                                                    while 1

                                                        F12! = Gravi(gamma!,s1_x!,s1_y!,s1_m!,s2_x!,s2_y!,s2_m!)
                                                        F13! = Gravi(gamma!,s1_x!,s1_y!,s1_m!,s3_x!,s3_y!,s3_m!)
                                                        F23! = Gravi(gamma!,s2_x!,s2_y!,s2_m!,s3_x!,s3_y!,s3_m!)
                                                        r12! = sqrt(sqr(s2_x! - s1_x!) + sqr(s2_y! - s1_y!))
                                                        r13! = sqrt(sqr(s3_x! - s1_x!) + sqr(s3_y! - s1_y!))
                                                        r23! = sqrt(sqr(s3_x! - s2_x!) + sqr(s3_y! - s2_y!))

                                                        if nnnul(s1_m!)

                                                            s1_vx! = s1_vx! + F12! / s1_m! * (s2_x! - s1_x!) / r12! + F13! / s1_m! * (s3_x! - s1_x!) / r13!
                                                            s1_vy! = s1_vy! + F12! / s1_m! * (s2_y! - s1_y!) / r12! + F13! / s1_m! * (s3_y! - s1_y!) / r13!

                                                        endif

                                                        if nnnul(s2_m!)

                                                            s2_vx! = s2_vx! + F12! / s2_m! * (s1_x! - s2_x!) / r12! + F23! / s2_m! * (s3_x! - s2_x!) / r23!
                                                            s2_vy! = s2_vy! + F12! / s2_m! * (s1_y! - s2_y!) / r12! + F23! / s2_m! * (s3_y! - s2_y!) / r23!

                                                        endif

                                                        if nnnul(s3_m!)

                                                            s3_vx! = s3_vx! + F13! / s3_m! * (s1_x! - s3_x!) / r13! + F23! / s3_m! * (s2_x! - s3_x!) / r23!
                                                            s3_vy! = s3_vy! + F13! / s3_m! * (s1_y! - s3_y!) / r13! + F23! / s3_m! * (s2_y! - s3_y!) / r23!

                                                        endif

                                                        s1_x! = s1_x! + s1_vx!
                                                        s1_y! = s1_y! + s1_vy!
                                                        s2_x! = s2_x! + s2_vx!
                                                        s2_y! = s2_y! + s2_vy!
                                                        s3_x! = s3_x! + s3_vx!
                                                        s3_y! = s3_y! + s3_vy!
                                                        Mal_es(s1_x!,s1_y!,s2_x!,s2_y!,s3_x!,s3_y!)
                                                        Sleep(100)
                                                        case GetASyncKeyState(13) : break

                                                    wend

                                                endproc

                                                declare e%
                                                WindowTitle "Animation mit OK starten"
                                                cls
                                                MCls 640,480,$FFFFFF
                                                var h& = Create("Dialog",%hWnd,"Parameter",5,5,210,240)
                                                Create("Text",h&,"Gravitationskonstante:",5,  5,100,20)
                                                Create("Text",h&,"Radius der Sonnen:"    ,5, 25,100,20)
                                                Create("Text",h&,"Masse Sonne 1:"        ,5, 45,100,20)
                                                Create("Text",h&,"Masse Sonne 2:"        ,5, 65,100,20)
                                                Create("Text",h&,"Sonnen-Geschw.:"       ,5, 85,100,20)
                                                Create("Text",h&,"Radius des Planeten:"  ,5,105,100,20)
                                                Create("Text",h&,"Masse des Planeten:"   ,5,125,100,20)
                                                Create("Text",h&,"Geschw. des Planeten:" ,5,145,100,20)
                                                var h1& = Create("Edit",h&,"0.667428",105,  5,100,20)
                                                var h2& = Create("Edit",h&,"33"      ,105, 25,100,20)
                                                var h3& = Create("Edit",h&,"10000"   ,105, 45,100,20)
                                                var h4& = Create("Edit",h&,"0"       ,105, 65,100,20)
                                                var h5& = Create("Edit",h&,"0"       ,105, 85,100,20)
                                                var h6& = Create("Edit",h&,"100"     ,105,105,100,20)
                                                var h7& = Create("Edit",h&,"50"      ,105,125,100,20)
                                                var h8& = Create("Edit",h&,"11"      ,105,145,100,20)
                                                var b& = Create("Button",h&,"OK",5,170,100,20)
                                                var a& = Create("Button",h&,"Abbruch",105,170,200,20)

                                                repeat

                                                    WindowTitle "Animation mit OK starten"
                                                    e% = 0

                                                    repeat

                                                        waitinput
                                                        case Clicked(b&) : e% = 1
                                                        case Clicked(a&) : e% = -1

                                                    until e%

                                                    case e% < 0 : break
                                                    SetFocus(%hWnd)
                                                    WindowTitle "Animation mit ENTER abbrechen"
                                                    main(320,240,val(GetText$(h1&)) , val(GetText$(h2&)),val(GetText$(h6&)) , val(GetText$(h3&)),val(GetText$(h4&)),val(GetText$(h7&)) , val(GetText$(h5&)),val(GetText$(h8&)))

               
until e% < 0 end

6 kB
Kurzbeschreibung: Quellkode
Hochgeladen:11/30/09
Downloadcounter175
Download
1.071 kB
Kurzbeschreibung: Program Doppelstern
Hochgeladen:11/30/09
Downloadcounter200
Download
 
Nico Madysa
11/30/09  
 




Thomas
Zielinski
After one Click on OK with the Voreinstellungen has the program gnadenlos aufgehangen. One Piece the Animation was Yes yet To sehn. but after a half-way turn the bullet and a Click into Einstellungsfenster wars past.
Greeting Thomas
 
XProfan X4; Win10 x64
Der Kuchen ist eine lüge!
11/30/09  
 




Nico
Madysa
have you got Enter pressed? the might well on whom NProcs lying. If I in that Window click, comes of course too "Keine Rückmeldung", but with pressure on Enter reagierts mostly still again.

it be because, your PC rechnet with Ner others Physics as of my.
 
Nico Madysa
11/30/09  
 




Thomas
Zielinski
Ah Okay. with Enter GEHTS then again. nevertheless is another winziges Anzeigeproblem

 
XProfan X4; Win10 x64
Der Kuchen ist eine lüge!
11/30/09  
 




Nico
Madysa
this is beabsichtigt. the Program should not schick his, separate one Doppelsternsystem simulate. therefore is too the dialog so hingeklatscht.
 
Nico Madysa
11/30/09  
 



"Keine Rückmeldung" becomes displayed, z.B. if one Process fully under Last and that the WProc too no Time to that Answer has. really is always "Keine Rückmeldung" ausserhalb of Waitinput - roughly seen. One Sleep changes nothing on "Keine Rückmeldung" - here bliebe z.B. one eigener Thread or yet sooner a TimerProc, so The XProfan-WProc too time Time to that "antworten" has.

The Message "Keine Rückmeldung" means means utterly not, that something abgestürzt or not functions - really only the degree hard on the works is.

cls with sleep 100000 gives too "keine Rückmeldung" if one The wProc attempts To question z.B. with lauter Klicks aufs hWnd. ^^
 
11/30/09  
 




Nico
Madysa
well, then see I time, whether I a Thread from it can make.
 
Nico Madysa
11/30/09  
 



went now very simply even by Thread.Start [...]  . ^^
 
03/21/10  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

11.367 Views

Untitledvor 0 min.
Frank04/16/21
p.specht05/18/20
Rc12/24/15
Georg Teles04/15/13
More...

Themeninformationen



Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie