|
Post by Tom Mulgrew on May 3, 2006 3:09:23 GMT -5
I made a little program that graphs functions in 3D. ResizeText(80,30) dim formula$, code dim x#, y#, z#, t# do input "Z#=", formula$ formula$ = "Z#=" + formula$ code = Compile(formula$) if code = 0 then printr CompilerError() endif loop until code <> 0 dim range#, zoom#, XAng#, YAng#, sx#, sy# range# = 10: zoom# = -20: xAng# = 20 TextMode(TEXT_OVERLAID) cls: print formula$ do glClear(GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT) glLoadIdentity() glTranslatef(0, 0, zoom#) glRotatef(-90, 1, 0, 0) glRotatef(XAng#, 1, 0 ,0) glRotatef(YAng#, 0, 0, 1) glBegin(GL_POINTS) for sy# = -1 to 1 step .05 for sx# = -1 to 1 step .05 x# = sx# * range# y# = sy# * range# Execute(code) glVertex3f(x#, y#, z#) next next glEnd() DrawText() SwapBuffers() while SyncTimer(10) XAng# = XAng# + mouse_yd() * 30 YAng# = YAng# + mouse_xd() * 30 zoom# = zoom# + mouse_wheel() t# = t# + 0.01 wend loop You basically type in a formula to calculate Z#. You can use X#, Y# as the input position. And T# is the number of seconds the program has been running. Some examples are: x#*y#*.1 x#/y# sin(x#) sin(x#)*sin(y#) sin(x#)*sin(y#)*sin(t#) sin(length(vec2(x#,y#))) length(vec2(x#,y#)) x#*x#*sin(t#) sin(t#)*(length(vec2(x#,y#))<5) See if you can guess what they will look like -Tom
|
|
|
Post by wybiral on May 3, 2006 5:15:35 GMT -5
Thats pretty neat.
Z#=Sin(X#/2)+Cos(Y#/2)
|
|