'=========================================================================== ' Subject: 3D SURFACE PLOT Date: 12-14-98 (14:35) ' Author: Dave Navarro, Jr. Code: PB ' Origin: dave@powerbasic.com Packet: GRAPHICS.ABC '=========================================================================== '3D Surface plot 'From "Microcomputer Graphics Techniques and Applications" by Donald Hearn 'Ported to PB by Dave Navarro (dave@powerbasic.com) $LIB GRAPH ON SCREEN 12 WINDOW (-4, -3) - (4, 3) RHO = 50 '30 D = 10 THETA = 1 S1 = SIN(THETA) C1 = COS(THETA) PHI = 1 S2 = SIN(PHI) C2 = COS(PHI) FOR x = 15 TO -15 STEP -.5 FL = 0 FOR Y = -10 TO 10 Z = F(x,y) XE = -X*S1 + Y*C1 YE = -X*C1*C2 - Y*S1*C2 + Z*S2 ZE = -X*S2*C1 - Y*S1*S2 - Z*C2 + RHO SX = D*XE/ZE SY = D*YE/ZE IF FL = 0 THEN FL = 1 PSET (SX, SY), 2 END IF LINE - (SX, SY), 2 NEXT Y NEXT x SLEEP SCREEN 0, 0, 0 FUNCTION F(x, y) FUNCTION = 3*COS(.05*(X*X + Y*Y)) END FUNCTION