Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!mips!apple!well!levine From: levine@well.sf.ca.us (Ron Levine) Newsgroups: comp.graphics Subject: Right-handed coordinates in PHIGS Message-ID: <24534@well.sf.ca.us> Date: 1 May 91 07:55:04 GMT Distribution: comp Lines: 94 It is part of the PHIGS specification that all coordinate systems are right-handed. What does that mean? Why does that matter in practice? The recent book on PHIGS from the U.K. defines "right-handed coordinate system" with the help of a drawing of a CRT Workstation with x and y axes in the plane of the screen and a z axis sticking out toward the eye of the viewer. It defines handedness by saying, "in a right handed coordinate system, the z axis comes out of the screen as z increases. ... If the z axis were to go into the screen the system would be called left- handed, and it would be the mirror image of a right-hand system", along with the italics and boldface which indicate a definition. That is all that this book says on the subject. What if the workstation and its screen were not in the picture? How could I tell my right from my left, then, I wonder? And then, if I turned the workstation around and left the coordinates fixed, the old positive z would then be the negative z and that would appear to change the handedness by this definition. Does the handedness of an arbitrary fixed coordinate system depend on the position or orientation of a phantom workstation, I wonder? At least two of the five coordinate systems which are always present in PHIGS are not necessarily oriented in any special way with respect to the workstation display surface. What do I mean by their handedness? And who cares? When does it matter whether a coordinate system is right or left handed? How can the PHIGS programmer avoid introducing a left handed coordinate system? What could be the consequences if she inadvertently does so? Is it even possible to inadvertently do so? Most mathematician/PHIGS programmers should be able to answer all these questions, precisely and operationally. I think that perhaps many computer scientist/PHIGS programmers cannot. All 3D coordinate systems fall into one of two equivalence classes, one arbitrarily called right handed, the other left. In this discussion, a coordinate system is defined by an ordered set of mutually perpendicular axes, and the ordering is important. That is, the xyz system and the yxz system are different. And they are of different handedness classes. But xyz and yzx have the same handedness. The positive senses of the axes are also important: xyz has different handedness from (-x)yz, but the same as (-x)(-y)z. You can tell whether two arbitrary 3D systems xyz and uvw have the same handedness by looking at the matrix of the transformation between them, in particular the determinant of the 3x3 linear part. If this determinant is positive, the two systems have the same handedness, otherwise different. xyz -> (-x)yz is reflection in the plane x=0,. xyz -> yxz is reflection in the plane y=x, both like reflection in a mirror. So we see that a coordinate system and its mirror image are of opposite handedness. Because our two hands are mirror images of each other, we are able to use them as mnemonics for which class is which. Hold your right hand with the thumb and index finger approximately mutually perpendicular in the plane of the palm, and the middle finger approximately perpendicular to the plane of the palm. Now go look for a coordinate system. When you find it, orient your right hand so that the thumb points along the x axis, the index finger along the y axis. If the middle finger points along the z axis, the coordinate system is right handed. If the middle finger points along the (-z) axis, the coordinate system is left handed. Now, you don't need to carry your workstation around with you, your hands will do. Very little in computer graphics, or even physics, depends on the handedness of the coordinate system. The most important thing I can think of is the formula for computing the cross product of two vectors from their cartesian components. This is not a coordinate invariant. Generally, we like to base computational algorithms on formulas which are coordinate invariant--you change coordinate system, you get the same result. Unfortunately, the cross product is not coordinate invariant. The good news is that it's not too coordinate-dependent, because it depends only on the handedness of the coordinate system, and it varies only by a multiplicative sign between systems of different handedness. But it's mostly due to this non-invariance of the cross product that we have to pay any attention at all to coordinate handedness. What does this have to do with PHIGS? What are the answers to the questions in the paragraph above beginning "Who cares"? Stay tuned. More when I get back from a trip to New York, leaving in the morning. Ron Levine Dorian Research, Inc.