用BASIC畫個圖送給AutoCAD
機械系劉陳祥老師作
'----------- The 2D Function Script File Maker ---------- CLS DEF FNY (X) = X * EXP(2 * COS(A / 2) + SIN(3 * A)) / 4 K = 3.1415926# / 180 N = 200 X1 = -400 X2 = 400 Y1 = -300 Y2 = 300 DX = (X2 - X1) / N OPEN "FPLT2D.SCR" FOR OUTPUT AS #1 PRINT #1, "LIMITS" WRITE #1, X1, Y1 WRITE #1, X2, Y2 PRINT #1, "ZOOM" PRINT #1, "A" PRINT #1, "PLINE" FOR X = X1 TO X2 STEP DX A = X * K Y = FNY(X) PRINT "X="; X!, "Y="; Y! WRITE #1, X, Y NEXT X PRINT #1, "" CLOSE #1 END |
圖 一 |
'------------ The 3D Function Script File Maker --------------------- CLS DEF FNZ (X, Y) = R * EXP(COS(K * X) * SIN(K * Y)) K = 3.1415926# / 180 M = 50 N = 40 X1 = -300 X2 = 300 Y1 = -200 Y2 = 200 DX = (X2 - X1) / M DY = (Y2 - Y1) / N OPEN "FPLT3D.SCR" FOR OUTPUT AS #1 PRINT #1, "LIMITS" WRITE #1, X1, Y1 WRITE #1, X2, Y2 PRINT #1, "VPOINT" PRINT #1, "2,-1,3" PRINT #1, "ZOOM" PRINT #1, "A" PRINT #1, "3DMESH" WRITE #1, M + 1 WRITE #1, N + 1 FOR I = 0 TO M FOR J = 0 TO N X = I * DX + X1 Y = J * DY + Y1 R = 100 * SIN(SQR(X * X + Y * Y) * K) Z = FNZ(X, Y) PRINT "("; I; ","; J; ") ="; WRITE X, Y, Z WRITE #1, X, Y, Z NEXT J NEXT I CLOSE #1 END |
圖 二 |