Plotting a wormhole
Posted: Sun Feb 15, 2015 6:01 pm
REM Plotting 3d worm hole
REM iPhone 6 plus / 8.3 b1
REM its slow, any thoughts?
REM enjoy
'graphics screen
graphics
'math
pi=3.1415
'Set the center of the screen..
cntx = Screen_Width()
cnty = Screen_Height()
'Set are camera lens..
LENS = 256
'Start timer for frames per second
T = TIMER
'Main LOOP
loop:
refresh off
r = 40 ' Radius of worm hole 40
z = z + 1 'Z cord of worm hole
Rang = ang * PI/180 'Degrees to Radians
x = r * COS(Rang) 'Polar to Cartesain X
y = r * SIN(Rang) 'Polar to Cartesain Y
Dist = LENZ - z ' Find distance
IF z > 256 THEN ' Check for max Z,..
z = 0 'If true, reduce back to 0
END IF 'End code block
IF z > 0 AND z < 256 THEN 'Make sure z is still on screen
nx = cntx + (LENS * x) / Dist 'Find new X
ny = cnty - (LENS * y) / Dist 'Find new Y
ELSE 'So we don't divide by 0
END IF 'End code block
draw COLOR 0, 0, z/255 'Place blue pixel
draw PIXEL nx, ny
draw COLOR 0, z/255, 0 'Place green pixel
draw PIXEL nx + 1, ny - 1
ang = (ang + 1)%360 'Add angle, MOD keeps it from going over 360
F = F + 1 'Frame counter
refresh on
GOTO loop ' end LOOP
PRINT "Average FPS:"; F / (TIMER - T)' Frames per second equation.
pause 1 'Wait until screen is pressed..
REM iPhone 6 plus / 8.3 b1
REM its slow, any thoughts?
REM enjoy
'graphics screen
graphics
'math
pi=3.1415
'Set the center of the screen..
cntx = Screen_Width()
cnty = Screen_Height()
'Set are camera lens..
LENS = 256
'Start timer for frames per second
T = TIMER
'Main LOOP
loop:
refresh off
r = 40 ' Radius of worm hole 40
z = z + 1 'Z cord of worm hole
Rang = ang * PI/180 'Degrees to Radians
x = r * COS(Rang) 'Polar to Cartesain X
y = r * SIN(Rang) 'Polar to Cartesain Y
Dist = LENZ - z ' Find distance
IF z > 256 THEN ' Check for max Z,..
z = 0 'If true, reduce back to 0
END IF 'End code block
IF z > 0 AND z < 256 THEN 'Make sure z is still on screen
nx = cntx + (LENS * x) / Dist 'Find new X
ny = cnty - (LENS * y) / Dist 'Find new Y
ELSE 'So we don't divide by 0
END IF 'End code block
draw COLOR 0, 0, z/255 'Place blue pixel
draw PIXEL nx, ny
draw COLOR 0, z/255, 0 'Place green pixel
draw PIXEL nx + 1, ny - 1
ang = (ang + 1)%360 'Add angle, MOD keeps it from going over 360
F = F + 1 'Frame counter
refresh on
GOTO loop ' end LOOP
PRINT "Average FPS:"; F / (TIMER - T)' Frames per second equation.
pause 1 'Wait until screen is pressed..