Re: how to define theta and phi of a sphere in IDL [message #68586] |
Sat, 14 November 2009 22:20 |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Nov 15, 3:33 am, nisha katyal <nishahans...@gmail.com> wrote:
> No, actually i do not want to define it that way. I want to define
> x,y,z cordinates in terms of r,theta,phi. i.e
> x=r*sin(theta)cos(phi)
> y=r*cos(theta)sin(phi)
> z=r*cos(theta)
>
> I don not kno the difference in defining theta and phi....
Don't you mean y=r*sin(theta)sin(phi)? If so, theta is the angle from
the north pole to the parallel where your point is (90°-latitude), and
phi is the longitude. And David was saying that this conversion could
be done as
xyz=cv_coord(from_sphere=[phi,!dpi/2d0-theta,r],/to_rect)
|
|
|
Re: how to define theta and phi of a sphere in IDL [message #68587 is a reply to message #68586] |
Sat, 14 November 2009 22:11  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
nisha katyal writes:
> No, actually i do not want to define it that way. I want to define
> x,y,z cordinates in terms of r,theta,phi. i.e
> x=r*sin(theta)cos(phi)
> y=r*cos(theta)sin(phi)
> z=r*cos(theta)
>
> I don not kno the difference in defining theta and phi....
Well, maybe a picture will help:
http://en.wikipedia.org/wiki/Spherical_coordinate_system
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: how to define theta and phi of a sphere in IDL [message #68588 is a reply to message #68587] |
Sat, 14 November 2009 21:33  |
nisha katyal
Messages: 2 Registered: November 2009
|
Junior Member |
|
|
On Nov 15, 10:18 am, David Fanning <n...@dfanning.com> wrote:
> nisha katyal writes:
>> I have to draw spheres using idl . I want to define x,y,z in terms of
>> r,theta and phi. Do i have to define theta and phi both as following:
>
>> IDL> phi=2*!pi*(findgen(npoints)/(npoints-1))
>
> You can use CV_COORD to convert back and forth from
> polar, spherical, and rectangular coordinates. You
> don't have to do it yourself.
>
>> And also if i want to plot,should i plot x,z or y,z or x,y?
>
> Generally, if you are plotting on a rectangular
> coordinate system, you will need rectangular coordinates.
> But you can do this conversion just before plotting.
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
No, actually i do not want to define it that way. I want to define
x,y,z cordinates in terms of r,theta,phi. i.e
x=r*sin(theta)cos(phi)
y=r*cos(theta)sin(phi)
z=r*cos(theta)
I don not kno the difference in defining theta and phi....
|
|
|
Re: how to define theta and phi of a sphere in IDL [message #68589 is a reply to message #68588] |
Sat, 14 November 2009 21:18  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
nisha katyal writes:
> I have to draw spheres using idl . I want to define x,y,z in terms of
> r,theta and phi. Do i have to define theta and phi both as following:
>
> IDL> phi=2*!pi*(findgen(npoints)/(npoints-1))
You can use CV_COORD to convert back and forth from
polar, spherical, and rectangular coordinates. You
don't have to do it yourself.
> And also if i want to plot,should i plot x,z or y,z or x,y?
Generally, if you are plotting on a rectangular
coordinate system, you will need rectangular coordinates.
But you can do this conversion just before plotting.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|