[comp.graphics] Polar to Rectangular transformation.

abed@saturn.wustl.edu (Abed M. Hammoud) (03/16/91)

	Hello, 

	I have a small question, Its an easy one, so I hope I will
	not get flamed...

	A friend of mine wants to plot a set of Polar coordinates data
	in 3D. The data is in the form:

			r0, phi0, z0
			r1, phi1, z1
			.   .     .
			.   .     .
			rn, phin, zn

	I wrote a routine for him that takes this data set and do the
	obvious polar to rectangular transformation:

		x=round(r*cos(phi)*nbin+nbin+1)
		y=round(r*sin(phi)*nbin+nbin+1)
		X(x,y)=z

	The results I get is acceptable, but since I have to round x
	and y to integer numbers I loose some accuracy, and because
	there is a small (not large enough) number of polar coordinates
	samples the 3D function I get is not smooth.

	Also, I have to pass to the routine the number of samples that
	correspond to maximum radius, (nbin). nbin determines how big
	the rectangular array X will be.

		So, my question is; is this the best way of dealing with
	the problem ?. My friend seems to think that there must be a better
	way. He checked Auto-Cadd and there they seem to have a routine
	that do the same job but when you call the function you don't
	have to pass an equivalent of nbin, which my routine needs.

Notes:
	(Auto-cadd is $3000 and he cannot afford to buy it).
	(The routine I wrote uses matlab).
	(I can interpolate to make the function smoother, that will
	make the 2D array even bigger..)

	Any suggestion are appreciated....

	Thanks....

	--------------------------------------------------------------
	| Abed  M. Hammoud			abed@saturn.wustl.edu|
	| Washington University.	        office:(314)726-7547 |
	| Electronic Systems & Signals Research Laboratory.          |
	| Dept. of Electrical/Biomedical Engineering.		     |
	| St.Louis Mo U.S.A                                          |
	--------------------------------------------------------------