atan2 for quaternions?greenspun.com : LUSENET : quaternions : One Thread |
Hello - straight to point - Maple 7 defines the arctangent for 2 complex arguments -> arctan(a+I*b,c+I*d) -> the answer is really long if fully expanded, I won't write it hear. Question is, has such a function been defined for quaternions? If so, what is the definition? Would be cool because then I avoid dividing by zero, no special cases. Even if the answer is 10 pages long, as long as it is known, please let me know the formula/equation! Thanks in advance.
-- Robert Blair Aldridge III (raldridg@digipen.edu), September 10, 2003
Hello Robert:Don't think I have an answer for you, but do have a few thoughts, even some animations to look at.
I have figured out how to translate a wide variety of unary complex trig functions into quaternions. For a complete list of the algebra, go here:
http://world.std.com/%7Esweetser/quaternions/intro/tools/tools.html
The basic idea is that whenever one sees an "i" in an equation, for quaternions, you use the 3-vector over the norm of the 3-vector. If someone _gives_ me a formula with complex numbers, I use that rule to translate it into quaternions (in C, Java, Javascript, or Perl, I have working libraries in all four, and someone made one in Python). If you can find the code for the Maple definition for arctan2 of a complex number, it can be ported.
On to your specific question. The tangent function has a periodicity of pi, not two pi. This means that the points are double-valued. Tangent's inverse, ArcTan, also has a period of pi. If one takes the ArcTan of 5/5, the angle in radians is pi/4, or 45 degrees. What upsets people is the ArcTan of (-5)/(-5) is the same. "That's in the lower quadrant!" they shout. I want to stay away from any function where 1 and 1 written another way gives a different value.
ArcTan is a unary function, taking only one number ever. ArtTan2 is binary. In Mathematica at least, including the imaginary part of the number does not change the result of ArcTan2 in any way (test if that is the case for Maple too). Basically it calculates Artcan (a/b) and then figures out if it needs to add pi to a depending on the quadrant a and b are in.
Quaternions are essentially three complex numbers that share a real number. For the quaternion (t, x, y, z), one could determine the quadrant (t, x) was in.the third quadrant, where both were negative. The next complex number, (t, y), t is negative, but y could be either negative or positive. Looks like the real t axis must be verticle, so that (t, y) is in the third or fourth quadrant, and one will need to add in pi.
That's about all I can figure out for now.
If you are into number driven animations, you might want to look at how I have animated complex and quaternion trig functions. Definietly an odd form of entertainment. I doubt your profs have ever seen anything like it, because it is not vector or pixel based. Instead it uses quaternions for all input and output. You will need a Mozilla based browser (ie NOT IE) such as Netscape 7.
doug
Dynamic graphs URL: http://sdm.openacs.org/wp/display/1238/
-- Doug Sweetser (sweetser@alum.mit.edu), September 11, 2003.