Plotting a point on the sphere at given (s,t) angles

There's already a question and it has an answer here, however it doesn't work the way I expect it.

# Assume my radius is 1 for simplicity

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

When t=0, regardless of my s,

(x,y,z)=(0,0,1)  

# Since sin 0 = 0 on x 
# and y and z is independent of s

So here's how my world is

enter image description here

But actually when s increases, the point on the sphere varies, doesn't remain at (0,0,1). For eg. if my s=(-45)deg and t=0, point on sphere should be (0,0.707,0.707) right?

UPDATE: Here's what I need:

(s,t)   |  (x,y,z)
---------------
(0,0)   |  (0,0,1)
(45,0)  |  (.707,0,0.707)
(90,0)  |  (1,0,0)
(180,0) |  (0,0,-1)
(270,0) |  (-1,0,0)
(0,-45) | (0,0.707,0.707)
(0,45)  | (0,-0.707,0.707)

But I don't get those results from the above equations...! What do I do?

Upvotes: 0

Views: 796

Answers (1)

Spektre
Spektre

Reputation: 51845

with your formula t=0 means that you are at pole so the radius is zero. No matter what s is the output should be always (x,y,z)=(0,0,1). If you need the standard spherical coordinates instead use this:

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

s = <0,360> [deg]
t = <-90,+90> [deg]

for (s=45deg,t=0deg) it should return (x,y,z)=(0.707,0.707,0.000)

PS. I am not sure why you have mixed coordinates y,z instead of x,y in OP.

[Edit1]

To match your image reference frame try to use these:

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

s = <0,360> [deg]
t = <-90,+90> [deg]

Upvotes: 3

Related Questions