FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Suggestions
   Software Suggestions
(Moderator: fry)
   cartesian to polar / polar to cartesian
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: cartesian to polar / polar to cartesian  (Read 836 times)
Dimitre

WWW
cartesian to polar / polar to cartesian
« on: May 19th, 2003, 4:34pm »

I think it could be nice if processing have commands to make the conversion of coorinates system.
I use a tool called filtermeister ( www.filtermeister.com - photoshop plugins development) to test computer graphics, like in processing.
There are four commands that helps in that kind of conversion. here are they:
c2d(x,y); - converts the cartesian to direction (angle)
c2m(x,y); - converts the cartesian to magnitude (radius)
r2x(d,m); - converts polar to cartesian X
r2y(d,m); - converts polar to cartesian Y
 
mmm, it sounds like a op art machine
 
fry


WWW
Re: cartesian to polar / polar to cartesian
« Reply #1 on: May 20th, 2003, 7:57pm »

as someone who has made use of such functions, i could probably be convinced that they should be in the api.. i'll put them on the list and see what happens.
« Last Edit: May 20th, 2003, 7:57pm by fry »  
Dimitre

WWW
Re: cartesian to polar / polar to cartesian
« Reply #2 on: May 23rd, 2003, 11:15pm »

I don't know if is the best way to do, but I think it worked:
Code:
// cartesian to angle
float c2a (float x, float y){
  float angle = (atan2(y,x) * 180/PI);
  return angle;
}
 
// cartesian to magnitude (radius)
float c2m (float x, float y){
  float magnitude = (sqrt(sq(x) + sq(y)));
  return magnitude;
}

I started with functions returning an Int, but later I needed float for more resolution.
 
it is running at http://dmtr.org/generative/?id=46
« Last Edit: May 23rd, 2003, 11:16pm by Dimitre »  
fry


WWW
Re: cartesian to polar / polar to cartesian
« Reply #3 on: Jun 24th, 2003, 9:14pm »

cool, thanks.. i was thinking of the 3D case but the 2D makes even more sense.
 
Pages: 1 

« Previous topic | Next topic »