include "Plot.t"

put "2D and 3D Plotting Demonstration"
setscreen("nocursor")

%
%	Some useful constants
%

const pi:  real := 3.141592654
const pi4: real := 3.141592654/4
const pi8: real := 3.141592654/8
const nt:  int := 8
const ns:  int := 8


%
%	Parametric functions for a circle of radius 1.
%

function circx(t: real): real;
	result(cos(t))
end circx


function circy(t: real): real;
	result(sin(t))
end circy



%
%	Parametric functions for a sphere of radius 1.
%
function sphx(theta,phi: real): real;
	result(cos(theta)*sin(phi))
end sphx

function sphy(theta,phi: real): real;
	result(sin(theta)*sin(phi))
end sphy

function sphz(theta,phi: real): real;
	result(cos(phi))
end sphz



%
%	Parametric functions for an ellipse
%

function ellx(theta,phi: real): real;
	result(1.5*cos(theta)*sin(phi))
end ellx

function elly(theta,phi: real): real;
	result(0.75*sin(theta)*sin(phi))
end elly

function ellz(theta,phi: real): real;
	result(0.5*cos(phi))
end ellz


%
%	Let's plot something
%

Plot.SetScale(100,100)
Plot.SetOffset(150,150)
Plot.SetColour(1)
Plot.Plot2D(circx,circy,0,2*pi,nt)

Plot.SetRotation(pi8,pi8,pi8)
Plot.SetColour(2)
Plot.SetOffset(500,100)
Plot.Plot3D(sphx,sphy,sphz, 0,2*pi,ns, 0,pi,nt)

Plot.SetColour(5)
Plot.SetOffset(400,250)
Plot.Plot3D(ellx,elly,ellz, 0,2*pi,ns, 0,pi,nt)
