Home | Download | Screen shots | Discussion | Documentation | Links |
---|
00001 // 00002 // Vrml 97 library 00003 // Copyright (C) 1998 Chris Morley 00004 // Copyrights on some portions of the code are held by others as documented in the code. 00005 // Permission to use this code for any purpose is granted as long as all other copyrights 00006 // in the code are respected and this copyright statement is retained in the code and 00007 // accompanying documentation both online and printed. 00008 // 00009 /* 00010 * (c) Copyright 1993, 1994, Silicon Graphics, Inc. 00011 * ALL RIGHTS RESERVED 00012 * Permission to use, copy, modify, and distribute this software for 00013 * any purpose and without fee is hereby granted, provided that the above 00014 * copyright notice appear in all copies and that both the copyright notice 00015 * and this permission notice appear in supporting documentation, and that 00016 * the name of Silicon Graphics, Inc. not be used in advertising 00017 * or publicity pertaining to distribution of the software without specific, 00018 * written prior permission. 00019 * 00020 * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" 00021 * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, 00022 * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR 00023 * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON 00024 * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, 00025 * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY 00026 * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, 00027 * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF 00028 * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 00029 * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON 00030 * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE 00031 * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. 00032 * 00033 * US Government Users Restricted Rights 00034 * Use, duplication, or disclosure by the Government is subject to 00035 * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph 00036 * (c)(1)(ii) of the Rights in Technical Data and Computer Software 00037 * clause at DFARS 252.227-7013 and/or in similar or successor 00038 * clauses in the FAR or the DOD or NASA FAR Supplement. 00039 * Unpublished-- rights reserved under the copyright laws of the 00040 * United States. Contractor/manufacturer is Silicon Graphics, 00041 * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. 00042 * 00043 * OpenGL(TM) is a trademark of Silicon Graphics, Inc. 00044 */ 00045 /* 00046 * trackball.h 00047 * A virtual trackball implementation 00048 * Written by Gavin Bell for Silicon Graphics, November 1988. 00049 */ 00050 00051 #include "common.h" 00052 00053 #ifdef __cplusplus 00054 extern "C" { 00055 #endif 00056 00057 /* 00058 * Pass the x and y coordinates of the last and current positions of 00059 * the mouse, scaled so they are from (-1.0 ... 1.0). 00060 * 00061 * The resulting rotation is returned as a quaternion rotation in the 00062 * first paramater. 00063 */ 00064 void 00065 trackball(float q[4], float p1x, float p1y, float p2x, float p2y); 00066 00067 /* 00068 * Given two quaternions, add them together to get a third quaternion. 00069 * Adding quaternions to get a compound rotation is analagous to adding 00070 * translations to get a compound translation. When incrementally 00071 * adding rotations, the first argument here should be the new 00072 * rotation, the second and third the total rotation (which will be 00073 * over-written with the resulting new total rotation). 00074 */ 00075 void 00076 add_quats(float *q1, float *q2, float *dest); 00077 00078 /* 00079 * A useful function, builds a rotation matrix in Matrix based on 00080 * given quaternion. 00081 */ 00082 void 00083 build_rotmatrix(float m[4][4], float q[4]); 00084 00085 /* 00086 * This function computes a quaternion based on an axis (defined by 00087 * the given vector) and an angle about which to rotate. The angle is 00088 * expressed in radians. The result is put into the third argument. 00089 */ 00090 void 00091 axis_to_quat(float a[3], float phi, float q[4]); 00092 00093 00094 #ifdef __cplusplus 00095 } 00096 #endif