Author Topic: Functions 3D  (Read 1844 times)

Galileo

  • Guest
Functions 3D
« on: August 14, 2017, 04:45:24 PM »
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/2017
clear screen
LET LRG=256 : LET ALT=192
open window LRG,ALT
window origin "lb" : REM Origin of the graphical coordinates: left bottom
print "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 X
loop

sub 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: August 14, 2017, 06:17:19 PM by Galileo »

B+

  • Guest
Re: Functions 3D
« Reply #1 on: August 14, 2017, 07:30:37 PM »
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

  • Guest
Re: Functions 3D
« Reply #2 on: August 16, 2017, 06:15:34 PM »
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+

  • Guest
Re: Functions 3D
« Reply #3 on: August 16, 2017, 08:43:10 PM »
Thanks, wish I could copy/paste into input.

Galileo

  • Guest
Re: Functions 3D
« Reply #4 on: August 17, 2017, 04:15:23 PM »
You only have to uncomment the function you want to try.

B+

  • Guest
Re: Functions 3D
« Reply #5 on: August 17, 2017, 11:09:00 PM »
Yes that works, sort of...

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