We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › spherical coordinates to cartesian
Page Index Toggle Pages: 1
spherical coordinates to cartesian (Read 903 times)
spherical coordinates to cartesian
Jan 19th, 2006, 9:53pm
 
i have a strange problem by converting spherical coordinates to cartesian. it´s the aim to map coordinate points on a sphere. i have to convert the spherical coordinates i get from the gps to cartesian. but that doesn´t work so far. the strange is, that the results are equal to the following applet http://www.calc3d.com/ejavascriptcoordcalc.html ... that are useless values. the following applet delivers the right x,y and z values i think http://www.pha.jhu.edu/~javalab/spherical/spherical.html

what is wrong with my code? i would be glad for any ideas


float rad = 200;
float x, y, z;


void setup() {
 size (500, 500, P3D);
}


void draw() {
background(255);
stroke(255, 0, 0);
translate (250, 250, 0);

 x = rad * sin (90) * cos (0);
 y = rad * sin (90) * sin (0);
 z = rad * cos (90);
 
 println ("x="+x);
 println ("y="+y);
 println ("z="+z);

 point(z, y, x);
 point(0, 0);

noLoop();
 
}


Re: spherical coordinates to cartesian
Reply #1 - Jan 19th, 2006, 10:05pm
 
The problem is that you're using degrees, wheras processing uses radians. Instead of 90, you need to use HALF_PI.
Page Index Toggle Pages: 1