The QBasic Forum     RULES     Other Subforums, Links and Downloads

  
--

 Return to Index  

ZAPIS3L 0.00001 ;-)

November 20 2007 at 3:25 AM
petko10  (Login petko10)
R


Response to ZAPIS,ZAPIS3R 0.4 - record and read dots ,quite nice graphics

 
I made a new algorythm that works like through a lens (L) . I'm not sure if it's all correct ,because I again made the formula by hand . I'll do the translating in a few hours .

==============================================================
DECLARE SUB Coords (O5!, x1!, y1!, x2!, y2!)
DECLARE SUB Scales (O5!, n!, m!)
DECLARE SUB DelScales (O5!, n!, m!)
DECLARE FUNCTION dottodot (x!, y!, x1!, y1!)
DECLARE SUB prenesi (x!, y!, x1!, y1!, x2!, y2!, x3!, y3!)

TYPE Dot
x AS SINGLE
y AS SINGLE
z AS SINGLE
END TYPE

DIM SHARED T, L AS Dot
DIM SHARED r AS INTEGER

SCREEN 12
COLOR 2
2 :

INPUT "Enter a file from E:\Qbasic", file$
file$ = "E:\Qbasic\" + file$
CLS

i = 0

OPEN file$ FOR INPUT AS #6

WHILE (NOT EOF(6))

i = i + 1
INPUT #6, p, p1, p2

WEND

PRINT "There are"; i; "points"
INPUT "Continue?(1=no):", o
IF o = 1 THEN GOTO 5

TIMER ON
h = TIMER
CONST pi = 3.1415

INPUT "Enter the angle of sight:", s1
s2 = 3 / 4 * s1
L.x = 320
L.y = 240
L.z = 0

DO
g = g + 1
'IF TIMER > h + 20 THEN EXIT DO

CLOSE #6
OPEN file$ FOR INPUT AS #6
key$ = ""
key$ = INKEY$

IF key$ = "w" THEN a = a + 1
IF key$ = "s" THEN a = a - 1
IF key$ = "a" THEN c = c + 1
IF key$ = "d" THEN c = c - 1
IF key$ = "o" THEN
L.x = L.x + SIN(a1 * pi / 180) * 5
L.y = L.y + COS(a1 * pi / 180) * 5
L.z = L.z + SIN(c1 * pi / 180) * 5
END IF
IF key$ = "l" THEN
L.x = L.x - SIN(a1 * pi / 180) * 5
L.y = L.y - COS(a1 * pi / 180) * 5
L.z = L.z - SIN(c1 * pi / 180) * 5
END IF
IF key$ = "q" THEN EXIT DO

6 :

a1 = a * 5

IF a1 <= -360 OR a1 >= 360 THEN
a = 0
GOTO 6
END IF
IF a1 < 0 THEN a1 = 360 + a1

c1 = c * 5

IF c1 <= -360 OR c1 >= 360 THEN
c = 0
GOTO 6
END IF
IF c1 < 0 THEN c1 = 360 + c1

o = 0
CLS

PRINT "T", T.x, T.y, T.z
PRINT "L", L.x, L.y, L.z, a1, c1
FOR i = 1 TO i - 1

INPUT #6, T.x, T.y, T.z

'T.x = T.x + L.x
'T.y = T.y + L.y
'T.z = T.z + L.z

b = 640 * ATN(T.z / (T.x - L.x)) * pi / 180 + s1 / 2 - 90 - c1
d = 480 * ATN(T.z / (T.y - L.y)) * pi / 180 + s2 / 2 - 90 - a1

b = -b
d = -d

PRINT b, d

IF o < 1 THEN
x = b
y = d
END IF
o = o + 1
g = 30
g1 = ATN((g / 2) / SQR((T.z - L.z) ^ 2 + (T.x - L.x) ^ 2)) * 640 / s1

LINE (x, y)-(b, d)
CIRCLE (b, d), g1
x = b
y = d
NEXT i

LOOP
PRINT a, a1, b, b1, b1a, b1b, c, c1, d, d1, d1a, d1b, g, T.x, T.y, T.z


5 :

INPUT "To restart enter 1:", o

IF o = 1 THEN GOTO 2

SUB DelScales (O5, n, m)

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

END SUB

FUNCTION dottodot (x, y, x1, y1)

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

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

END FUNCTION

SUB LINE1 (x, y, x1, y1, xm, ym)

LINE (x + xm, ABS(480 - (y + ym)))-(x1 + xm, ABS(480 - (y1 + ym)))

END SUB

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

x3 = x2 - (x1 - x)
y3 = y2 - (y1 - 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
===========================================================
Its very "buggy" ,I post it here at first only to have it in the net .


    
This message has been edited by petko10 on Dec 26, 2007 5:10 AM
This message has been edited by petko10 on Nov 20, 2007 6:29 AM
This message has been edited by petko10 on Nov 20, 2007 6:27 AM
This message has been edited by petko10 on Nov 20, 2007 6:16 AM


 
 Respond to this message   
Response TitleAuthorDate
 ZAPISL 0.5 - 3D observation ,pls comment :-)petko10Mar 30, 2008
 ZAPIS 0.9 - The pretty much finished version + print screen and example dotspetko10Jun 8, 2008
  The Dotspeko10Jun 10, 2008
  Hi Petko10, could you do me a revision favor in your post? Jun 10, 2008
   Me being me again :Dpetko10Jun 11, 2008
    Thanks for editing to remove our italics bug. Tried it out and it works fine now! :) Jun 11, 2008
     As I forgot to mentionpetko10Jun 13, 2008
  A separate Render SUBpetko10Jun 11, 2008
 Copyright © 1999-2008 Network54. All rights reserved.   Terms of Use   Privacy Statement