# Gravitational point 3D 0.3

November 15 2007 at 1:00 PM
R

Response to ProgramList petko10

That's a program that I wrote right after the Gravitational point 2D ,but I didn't fill it in here because I couldn't get the visualisation all right . Now the program writes down the coordinates to E:\Qbasic\gravity.txt (you can change it without really knowing the code - it snot bound to it ,just replace all the paths) . And the graphic can be opened in the ZAPIS3R.II that I'll post next .

=========================================================

DECLARE SUB Scales (O5!, n!, m!)
DECLARE FUNCTION dottodot3 (x!, y!, z!, x1!, y1!, z1!)
DECLARE SUB prenesi3 (x!, y!, z!, x1!, y1!, z1!, x2!, y2!, z2!, x3!, y3!, z3!)
DECLARE FUNCTION dottodot (x!, y!, x1!, y1!)
DECLARE SUB prenesi (x!, y!, x1!, y1!, x2!, y2!, x3!, y3!)
DIM SHARED xe, ye AS INTEGER
SCREEN 12
COLOR 2

open "E:\Qbasic\gravity.txt" for output as #1
open "E:\Qbasic\gravity.txt" for input as #2

2 :
CLS

PRINT "PROGRAM FOR GRAVITY POINT SIMULATION"

PRINT ""

O5 = 20
n = 160
m = 90

CALL Scales(O5, n, m)

PRINT "Enter the gravity point:"

INPUT "x:", xv
IF xv = 6666 THEN GOTO 5
INPUT "y:", yv
IF yv = 6666 THEN GOTO 5
INPUT "z:", zv
IF zv = 6666 THEN GOTO 5

CIRCLE (xv, yv), 5
CIRCLE (xv, yv), 150

PRINT "Enter the object (it's vector) :"

INPUT "x1:", x1
IF x1 = 6666 THEN GOTO 5
INPUT "y1:", y1
IF y1 = 6666 THEN GOTO 5
INPUT "z1:", z1
IF zv = 6666 THEN GOTO 5
INPUT "x2:", x2
IF x2 = 6666 THEN GOTO 5
INPUT "y2:", y2
IF y2 = 6666 THEN GOTO 5
INPUT "z2:", z2
IF zv = 6666 THEN GOTO 5

CIRCLE (x2, y2), 8 * 56 / z2
LINE (x1, y1)-(x2, y2)

INPUT "How many loops?:", O
IF O = 6666 THEN GOTO 5
INPUT "Gravity force (0-30):", vv1
IF vv1 = 6666 THEN GOTO 5

CLS

CIRCLE (xv, yv), 5
CIRCLE (xv, yv), 150
CIRCLE (x2, y2), 8 * 56 / z2
LINE (x1, y1)-(x2, y2)

xr = x2
yr = y2

FOR O = 1 TO O

FOR i = 1 TO 222200
NEXT i

LINE (x2, 480)-(x2, 480 - (O5 / 5 + 3)), 0, BF
LINE (0, y2)-(O5 / 5 + 3, y2), 0, BF

CALL Scales(O5, n, m)

v = dottodot3(xv, yv, zv, x2, y2, z2)

v1 = vv1
IF v < 5 THEN O = O - 1
IF v > 180 THEN v1 = 0
v1 = 6.672 * vv1 ^ 2 / v ^ 2

xv1 = x2 - ((x2 - xv) * v1 / v)
yv1 = y2 - ((y2 - yv) * v1 / v)
zv1 = z2 - ((z2 - zv) * v1 / v)

CALL prenesi3(x2, y2, z2, x1, y1, z1, xv1, yv1, zv1, xn, yn, zn)

'CALL scale(n, m, x2, y2, z2, xn, yn, zn, xr1, yr1)
'CALL prenesi(xr, yr, x2, y2, xr1, yr1, xr1, yr1)

LINE (x1, y1)-(x2, y2)
IF 8 * 56 / z2 > 239 OR 8 * 56 / z2 > y2 OR 8 * 56 / z2 > 480 - y2 OR 8 * 56 / z2 > x2 OR x * 56 / z2 > 640 - x2 THEN GOTO 7
IF x2 > 640 OR 0 > y2 > 480 THEN GOTO 7
CIRCLE (x2, y2), 8 * 56 / z2
7 :
6 :

write #1 ,x1,y1,z1

x1 = x2
y1 = y2
z1 = z2
x2 = xn
y2 = yn
z2 = zn

LINE (x2, 480)-(x2, 480 - (O5 / 5 + 3))
LINE (0, y2)-(O5 / 5 + 3, y2)

NEXT O
5 :

INPUT "To restart enter 1:", O

IF O = 1 THEN GOTO 2

FUNCTION dottodot (x, y, x1, y1)

xn! = x1 - x
yn! = y1 - y

dottodot = SQR(xn ^ 2 + yn ^ 2)

END FUNCTION

FUNCTION dottodot3 (x, y, z, x1, y1, z1)

xn! = x1 - x
zn! = z1 - z
yn! = y1 - y

c = SQR(xn ^ 2 + zn ^ 2)
dottodot3 = SQR(yn ^ 2 + c ^ 2)

END FUNCTION

SUB prenesi (x, y, x1, y1, x2, y2, x3, y3)

x3 = x2 - (x1 - x)
y3 = y2 - (y1 - y)

END SUB

SUB prenesi3 (x, y, z, x1, y1, z1, x2, y2, z2, x3, y3, z3)

x3 = x2 - (x1 - x)
y3 = y2 - (y1 - y)
z3 = z2 - (z1 - z)

END SUB

SUB scale (n, m, x1, y1, z1, x2, y2, z2, xr, yr)

x = (320 * (z1 + z2) / 2) / 600
IF x > 320 THEN x = 0
y = x * m / n
xd = 640 - x
yd = y

d = dottodot(x, y, xd, yd)

x = x1 - x2
y = y1 - y2

x = x * d / 640
y = y * d / 480

xr = x2 + x
yr = y2 + y

END SUB

SUB Scales (O5, n, m)

xe = 640 / O5
ye = 480 / O5

O6 = 0

FOR xe = 1 TO xe

O6 = O6 + O5
LINE (O6, 480)-(O6, 480 - O5 / 5)

NEXT xe

O6 = 0

FOR ye = 1 TO ye

O6 = O6 + O5
LINE (0, O6)-(O5 / 5, O6)

NEXT ye

LINE (n, 480)-(n, 480 - (O5 / 5 + 3))
LINE (0, m)-(O5 / 5 + 3, m)

END SUB

=========================================================

Some values for example ,as they get asked for : 400,240,150,200,200,175,202,203,173,loops ~100-200,force 30

 This message has been edited by petko10 on Nov 15, 2007 1:18 PM

 Respond to this message