tags:

views:

298

answers:

3

So coming from a flash background I have an OK understanding of some simple 2D trig. In 2d with I circle, I know the math to place an item on the edge given an angle and a radius using.

x = cos(a) * r;
y = sin(a) * r;

Now if i have a point in 3d space, i know the radius of my sphere, i know the angle i want to position it around the z axis and the angle i want to position it around, say, the y axis. What is the math to find the x, y and z coordinates in my 3d space (assume that my origin is 0,0,0)? I would think i could borrow the Math from the circle trig but i can't seem to find a solution.

p.s. If you can help, baby steps please... although i enjoy maths I'm no phd mathematician ;)

+2  A: 

You're looking for spherical coordinates. The wikipedia page includes formulas (in the "Cartesian coordinates" section). Since you're dealing with a sphere, your radius would be a constant.

Joe White
+1  A: 

You'll definitely want to look up spherical coordinate systems.

http://en.wikipedia.org/wiki/Spherical_coordinates

taserian
+10  A: 

Your position in 3d is given by two angles (+ radius, which in your case is constant)

x = r * cos(s) * sin(t)
y = r * sin(s) * sin(t)
z = r * cos(t)

here, s is the angle around the z-axis, and t is the height angle, measured 'down' from the z-axis.

second