Skip to content

3d polar coordinates in rgl function view3d()

2 messages · Peter Rossi, Duncan Murdoch

#
Dear all:

I'm enjoying using rgl and I want to set a specific viewpoint.

I understand that view3d()  will do so by setting the 3d polar
coordinate angles, theta and phi.

In standard polar coordinates, theta is the angle away from the X axis
in the X-Y plane and phi (inclination angle) is the angle between the
Z axis and the radius vector

It appears that when you use view3d()  theta is defined as the angle
away from the x axis in the X-Z plane and phi is the angle between the
Y axis and the radius vector.

When I use view3d(theta=0, phi=15), my image is flipped on the side
with the Y axis pointing upward and the Z axis pointing toward me.
This seems contrary to the standard definition of polar coordinates.

I have read the rgl help files but these do not define theta or phi.
I also looked at documentation on the rgl site to no avail.

I wonder if someone out there could enlighten me as to what I've got
wrong or how to translate properly between rgl definition and standard
polar coordinates.

thanks very much

peter rossi



--
  Peter E. Rossi
  James Collins Professor of Marketing, Statistics, and Economics
  UCLA | Anderson School
  110 Westwood Plaza, B4.06
  Los Angeles, CA 90095
  Tel: (773) 294-8616   |   Fax: (310) 206-7422
  perossichi at gmail.com |  www.perossi.org
  SSRN: http://papers.ssrn.com/author=22862
#
On 12-10-08 7:12 PM, Peter Rossi wrote:
That's incorrect, see below.
Those descriptions are both incomplete.  Rotations in 3D don't commute, 
so you need to give them in order:  e.g. "first rotate by x about y, 
then rotate by z about w."

I don't remember what theta and phi correspond to in those terms, but if 
you want to get fine control, set the userMatrix member of par3d() 
explicitly.
You could also read the source code -- it's open source.
You can't, it's not polar coordinates.  It's a sequence of rotations.

Duncan Murdoch