-- Graphing 3-D equations onto a 2-D graph grid 18-Sept-99 -- Hyperbolic Paraboloid -- uses sizeaxis() Xfun ~ The 3-D equation written in terms of X=..., Y=... and Z=... then I calculate cross-section (trace) arrays of {x,y,z} points. I next convert the 3-D point arrays to corresponding 2-D point arrays and do "plotline". The result is a trace sketch of various quadric surfaces in perfect perspective according to the placement of the Z-axis at an angle of 45° between the -X axis and -Y axis. by Eric Collins ~ a=1; b=4; c=1 TOPtrace=8 BOTTOMtrace=-TOPtrace RIGHTtrace=9 LEFTtrace=-RIGHTtrace FRONTtrace=5 POSTERIORtrace=-FRONTtrace GRID=22 ---- toggle for direcection orientation -- "0" = off, "1" = on pos=1 neg=0 Zax={{Xmin,Xmin}/2,{0,0},{Xmax,Xmax}/2} --plotline Zax --tic_adjuster=4 ---- Surface Equation fy(X,Z)=((X/a)^2-(Z/c)^2)/b fz(X,Y)=c*sqrt((X/a)^2-(Y*b)) fx(Y,Z)=a*sqrt((Y*b)+(Z/c)^2) ---- Array Variables Zint=fz(0,B) Z[z]=(z-2*Zint*5-1)*.1 dim[2*Zint*10+1] ZRint=fz(R,B) ZR[z]=(z-2*ZRint*5-1)*.1 dim[2*ZRint*10+1] --Xint=fx(T,0) -- X-intercept for top and bottom traces EX[ex]=(ex-(R-L)*5-1)*.1 dim[(R-L)*10+1] Yint=fy(0,T) ---- Trace coordinate arrays equations YZtrace={0,fy(0,Z),Z} YZtraceR={R,fy(R,ZR),ZR} YZtraceL={L,fy(L,ZR),ZR} XYtrace={EX,fy(EX,0),0} XZtrace={EX,0,fz(EX,0)} XZtraceT={EX,T,fz(EX,T)} XZtraceT2={EX,T,-fz(EX,T)} XZtraceB={EX,B,fz(EX,B)} XZtraceB2={EX,B,-fz(EX,B)} T=TOPtrace B=BOTTOMtrace R=RIGHTtrace L=LEFTtrace F=FRONTtrace P=POSTERIORtrace o=pos-neg ---- Array coordinate converter: (x,y,z) to (x,y) -- 3D to 2D coordinates YZtracept={YZtrace[1]-YZtrace[3]/2,YZtrace[2]-YZtrace[3]/2} plotline YZtracept YZtraceptR={YZtraceR[1]-YZtraceR[3]/2,YZtraceR[2]-YZtraceR[3]/2} plotline YZtraceptR YZtraceptL={YZtraceL[1]-YZtraceL[3]/2,YZtraceL[2]-YZtraceL[3]/2} plotline YZtraceptL XZtracept={XZtrace[1]-XZtrace[3]/2,XZtrace[2]-XZtrace[3]/2} plotline XZtracept plotline -XZtracept XZtraceptT={XZtraceT[1]-XZtraceT[3]/2,XZtraceT[2]-XZtraceT[3]/2} plotline XZtraceptT XZtraceptT2={XZtraceT2[1]-XZtraceT2[3]/2,XZtraceT2[2]-XZtraceT2[3]/2} plotline XZtraceptT2 XZtraceptB={XZtraceB[1]-XZtraceB[3]/2,XZtraceB[2]-XZtraceB[3]/2} plotline XZtraceptB XZtraceptB2={XZtraceB2[1]-XZtraceB2[3]/2,XZtraceB2[2]-XZtraceB2[3]/2} plotline XZtraceptB2 XYtracept={XYtrace[1]-XYtrace[3]/2,XYtrace[2]-XYtrace[3]/2} plotline XYtracept ta=tic_adjuster tics[t]=(t-Xmax+ta)*.5 dim[2*trunc(Xmax)] Ztics[t]={tics[t],tics[t]} Ztics2[t]={tics[t]-1/8,tics[t]} Ztics3[t]={tics[t]-1/4,tics[t]} plotline {Ztics[1],Ztics2[1],Ztics3[1]} plotline {Ztics[2],Ztics2[2],Ztics3[2]} plotline {Ztics[3],Ztics2[3],Ztics3[3]} plotline {Ztics[4],Ztics2[4],Ztics3[4]} plotline {Ztics[5],Ztics2[5],Ztics3[5]} plotline {Ztics[6],Ztics2[6],Ztics3[6]} plotline {Ztics[7],Ztics2[7],Ztics3[7]} plotline {Ztics[8],Ztics2[8],Ztics3[8]} plotline {Ztics[9],Ztics2[9],Ztics3[9]} plotline {Ztics[10],Ztics2[10],Ztics3[10]} plotline {Ztics[11],Ztics2[11],Ztics3[11]} plotline {Ztics[12],Ztics2[12],Ztics3[12]} plotline {Ztics[13],Ztics2[13],Ztics3[13]} plotline {Ztics[14],Ztics2[14],Ztics3[14]} plotline {Ztics[15],Ztics2[15],Ztics3[15]} plotline {Ztics[16],Ztics2[16],Ztics3[16]} plotline {Ztics[17],Ztics2[17],Ztics3[17]} plotline {Ztics[18],Ztics2[18],Ztics3[18]} plotline {Ztics[19],Ztics2[19],Ztics3[19]} Xmax=GRID Xmin=-GRID Ymin=-GRID Ymax=GRID Xdiv=4 Ydiv=4 Xshowgrid=off Yshowgrid=off --Xlabel="x" --Ylabel="y" sizeaxis(1,(Ymax-Ymin)/(Xmax-Xmin)):