Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
solar system4 (update)
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
uses GraphABC; const n = 4; tmax = 128000; t = 0.01; type velocity = record x: array [1..n, 1..3] of real; y: array [1..n, 1..3] of real; end; acceleration = record x: array [1..n] of real; y: array [1..n] of real; end; var x: array [1..n] of real; y: array [1..n] of real; r: array [1..n] of real; m: array [1..n] of real; var v: velocity; a: acceleration; begin // вводим начальные условия для первого тела m[1] := 2; x[1] := -1; y[1] := 0; v.x[1, 1] := 0.0; v.y[1, 1] := 0.0; v.x[1, 2] := 0; v.y[1, 2] := 1; v.x[1, 3] := 0.0; v.y[1, 3] := 0.5 * (v.y[1, 1] + v.y[1, 2]); // вводим начальные условия для второго тела m[2] := 2; x[2] := 1; y[2] := 0; v.x[2, 1] := 0.0; v.y[2, 1] := 0.0; v.x[2, 2] := 0; v.y[2, 2] := -1; v.x[2, 3] := 0.0; v.y[2, 3] := 0.5 * (v.y[2, 1] + v.y[2, 2]); r[1] := x[1] - x[2]; r[1] := sqr (x[1] - x[2]); r[1] := sqrt (r[1]); r[1] := - r[1] * r[1] * r[1]; r[2] := x[2] - x[1]; r[2] := sqr (x[2] - x[1]); r[2] := sqrt (r[2]); r[2] := - r[2] * r[2] * r[2]; SetWindowSize(800, 800); while x[1] < 10000 do begin a.x[1] := m[2] * (x[1]-x[2]) / r[1]; a.y[1] := m[2] * (y[1]-y[2]) / r[1]; x[1] := x[1] + t * v.x[1, 3]; y[1] := y[1] + t * v.y[1, 3]; v.x[1, 1] := v.x[1, 1] + t * a.x[1]; v.y[1, 1] := v.y[1, 1] + t * a.y[1]; v.x[1, 2] := v.x[1, 2] + (t+t ) * a.x[1]; v.y[1, 2] := v.y[1, 2] + (t+t ) * a.y[1]; v.x[1, 3] := 0.5 * (v.x[1, 1] + v.x[1, 2] ); v.y[1, 3] := 0.5 * (v.y[1, 1] + v.y[1, 2] ); r[1] := sqr(x[1] - x[2]) + sqr(y[1] - y[2]); r[1] := sqrt(r[1]); r[1] := -r[1] * r[1] * r[1]; a.x[2] := m[1] * (x[2]-x[1]) / r[2]; a.y[2] := m[1] * (y[2]-y[1]) / r[2]; x[2] := x[2] + t * v.x[2, 3]; y[2] := y[2] + t * v.y[2, 3]; v.x[2, 1] := v.x[2, 1] + t * a.x[2]; v.y[2, 1] := v.y[2, 1] + t * a.y[2]; v.x[2, 2] := v.x[2, 2] + (t+t ) * a.x[2]; v.y[2, 2] := v.y[2, 2] + (t+t ) * a.y[2]; v.x[2, 3] := 0.5 * (v.x[2, 1] + v.x[2, 2] ); v.y[2, 3] := 0.5 * (v.y[2, 1] + v.y[2, 2] ); r[2] := sqr(x[1] - x[2]) + sqr(y[1] - y[2]); r[2] := sqrt(r[2]); r[2] := -r[2] * r[2] * r[2]; ClearWindow; LockDrawing; line(0, 400, 800, 400); line(400, 0, 400, 800); circle(round(400 + 100 * x[1]), round(400 + 100 * y[1]), round(m[1] * 10 ) ); circle(round(400 + 100 * x[2]), round(400 + 100 * y[2]), round(m[2] * 10 ) ); line(round(400 + 100 * x[1]), round(400 + 100 * y[1]), round(400 + 100 * x[2]), round(400 + 100 * y[2])); circle(round(400 + 100 * (m[1]*x[1]+m[2]*x[2])/(m[1]+m[2])), round(400 + 100 * (m[1]*y[1]+m[2]*y[2])/(m[1]+m[2])), round( 3 ) ); Redraw; end; end.
Show compiler warnings
[
+
]
Show input
edit mode
|
history
|
discussion