### Author Topic: Functions 3D  (Read 364 times)

#### Galileo

• Jr. Member
• Posts: 77
##### Functions 3D
« on: 14. August 2017, 18:45:24 »
Hello again. A bit of nostalgia.

Code: [Select]
`// Adaptation from ZX Spectrum BASIC program "Funciones 3D", "RUN, Enciclopedia Práctica del Spectrum", nº 2, 1985// to Yabasic 2.78.0, by Galileo, 8/2017clear screenLET LRG=256 : LET ALT=192open window LRG,ALTwindow origin "lb" : REM Origin of the graphical coordinates: left bottomprint "Enter '(Q)uit' for exit the program"do LET XG=5: LET ZG=XG-2 LET CT=INT (LRG/XG/2) LET PF=INT (ALT/ZG/3) INPUT "F(X,Z)= " A\$ LET A\$=trim\$(upper\$(A\$)) if left\$(A\$,1)="Q" exit LET P=0 REM CALCULO GRAFICO DIM P(CT,PF) FOR A=-PF/2 TO PF/2 FOR B=-CT/2 TO CT/2 LET X=A*20/CT: LET Z=B*20/PF LET Y=EVAL(A\$) //LET Y=(X*X+Z*Z)/1000 //LET Y=LOG(1+(X+Z)*SIG(X+Z))/10 //LET Y=SIN(((60-X*X-Z*Z)*(ABS(SIN(60-X*X-Z*Z))+1))/3000) //LET Y=SIG(INT(23/(.00001+X*X+Z*Z)))/3+SIG(INT(55/(.00001+X*X+Z*Z)))/15 LET P((B+CT)/2,(A+PF)/2)=Y*ALT*(-1) IF P=8 LET P=0 LET P=P+1 NEXT B NEXT A clear window REM DIBUJO PLANO X-Y FOR Z=1 TO PF LET X1=XG*Z LET Z1=ALT/2+Z*ZG+20*(-1) new curve FOR X=1 TO CT LET XP=X1+X*XG LET ZP=Z1-X*ZG-P(X,Z) line to XP,ZP NEXT X NEXT Z REM DIBUJO PLANO Z-Y FOR X=1 TO CT LET X1=XG*X+PF*XG LET Z1=ALT/2-X*ZG+PF*ZG+20*(-1) new curve FOR Z=0 TO PF-1 LET XP=X1-Z*XG LET ZP=Z1-Z*ZG-P(X,PF-Z) line to XP,ZP NEXT Z NEXT Xloopsub EVAL(c\$) static linea linea=linea+1 c\$="sub s"+str\$(linea+1000000,"#######")+"():return "+c\$+":end sub" compile c\$ return execute(mid\$(c\$,5,8))end sub`
« Last Edit: 14. August 2017, 20:17:19 by Galileo »

#### B+

• Sr. Member
• Posts: 498
##### Re: Functions 3D
« Reply #1 on: 14. August 2017, 21:30:37 »
Hi Galileo,

Do you have suggestions for F(X, Z) = ?

Nothing I have tried has worked without error.

What function was used for screen shot?

#### Galileo

• Jr. Member
• Posts: 77
##### Re: Functions 3D
« Reply #2 on: 16. August 2017, 20:15:34 »
Hello. The comment functions work nice.

Code: [Select]
` //LET Y=(X*X+Z*Z)/1000 //LET Y=LOG(1+(X+Z)*SIG(X+Z))/10 //LET Y=SIN(((60-X*X-Z*Z)*(ABS(SIN(60-X*X-Z*Z))+1))/3000) //LET Y=SIG(INT(23/(.00001+X*X+Z*Z)))/3+SIG(INT(55/(.00001+X*X+Z*Z)))/15`

#### B+

• Sr. Member
• Posts: 498
##### Re: Functions 3D
« Reply #3 on: 16. August 2017, 22:43:10 »
Thanks, wish I could copy/paste into input.

#### Galileo

• Jr. Member
• Posts: 77
##### Re: Functions 3D
« Reply #4 on: 17. August 2017, 18:15:23 »
You only have to uncomment the function you want to try.

#### B+

• Sr. Member
• Posts: 498
##### Re: Functions 3D
« Reply #5 on: 18. August 2017, 01:09:00 »
Yes that works, sort of...

Could put the equations in a string array and run the strings through eval. Just a thought...