Max 5 API Reference
00001 /* 00002 * (c) Copyright 1993, 1994, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * Permission to use, copy, modify, and distribute this software for 00005 * any purpose and without fee is hereby granted, provided that the above 00006 * copyright notice appear in all copies and that both the copyright notice 00007 * and this permission notice appear in supporting documentation, and that 00008 * the name of Silicon Graphics, Inc. not be used in advertising 00009 * or publicity pertaining to distribution of the software without specific, 00010 * written prior permission. 00011 * 00012 * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" 00013 * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, 00014 * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR 00015 * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON 00016 * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, 00017 * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY 00018 * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, 00019 * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF 00020 * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN 00021 * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON 00022 * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE 00023 * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. 00024 * 00025 * US Government Users Restricted Rights 00026 * Use, duplication, or disclosure by the Government is subject to 00027 * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph 00028 * (c)(1)(ii) of the Rights in Technical Data and Computer Software 00029 * clause at DFARS 252.227-7013 and/or in similar or successor 00030 * clauses in the FAR or the DOD or NASA FAR Supplement. 00031 * Unpublished-- rights reserved under the copyright laws of the 00032 * United States. Contractor/manufacturer is Silicon Graphics, 00033 * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. 00034 * 00035 * OpenGL(TM) is a trademark of Silicon Graphics, Inc. 00036 */ 00037 /* 00038 * trackball.h 00039 * A virtual trackball implementation 00040 * Written by Gavin Bell for Silicon Graphics, November 1988. 00041 */ 00042 00043 /* 00044 * Pass the x and y coordinates of the last and current positions of 00045 * the mouse, scaled so they are from (-1.0 ... 1.0). 00046 * 00047 * The resulting rotation is returned as a quaternion rotation in the 00048 * first paramater. 00049 */ 00050 void 00051 trackball(float q[4], float p1x, float p1y, float p2x, float p2y); 00052 00053 /* 00054 * Given two quaternions, add them together to get a third quaternion. 00055 * Adding quaternions to get a compound rotation is analagous to adding 00056 * translations to get a compound translation. When incrementally 00057 * adding rotations, the first argument here should be the new 00058 * rotation, the second and third the total rotation (which will be 00059 * over-written with the resulting new total rotation). 00060 */ 00061 void 00062 add_quats(float *q1, float *q2, float *dest); 00063 00064 /* 00065 * A useful function, builds a rotation matrix in Matrix based on 00066 * given quaternion. 00067 */ 00068 void 00069 build_rotmatrix(float m[16], float q[4]); 00070 00071 // added rej 00072 void transform_point(const float in[4], const float m[16], float out[4]); 00073 00074 /* 00075 * This function computes a quaternion based on an axis (defined by 00076 * the given vector) and an angle about which to rotate. The angle is 00077 * expressed in radians. The result is put into the third argument. 00078 */ 00079 void 00080 axis_to_quat(float a[3], float phi, float q[4]); 00081 00082 // compute axis/angle rotation from quaternion. added by rej. 00083 void 00084 quat_to_axis(float q[4], float axis[3], float * phi); 00085 00086 void 00087 xyz_to_axis(float xyz[3], float axis[3], float * phi); 00088 00089 void 00090 axis_to_xyz(float axis[3], float phi, float xyz[3]); 00091 00092 // float vector routines 00093 void vzero(float *v); 00094 void vset(float *v, float x, float y, float z); 00095 void vsub(const float *src1, const float *src2, float *dst); 00096 void vcopy(const float *v1, float *v2); 00097 void vcross(const float *v1, const float *v2, float *cross); 00098 float vlength(const float *v); 00099 void vscale(float *v, float div); 00100 void vnormal(float *v); 00101 float vdot(const float *v1, const float *v2); 00102 void vadd(const float *src1, const float *src2, float *dst); 00103 00104 // double vector routines 00105 void vdzero(double *v); 00106 void vdset(double *v, double x, double y, double z); 00107 void vdsub(const double *src1, const double *src2, double *dst); 00108 void vdcopy(const double *v1, double *v2); 00109 void vdcross(const double *v1, const double *v2, double *cross); 00110 double vdlength(const double *v); 00111 void vdscale(double *v, double div); 00112 void vdnormal(double *v); 00113 double vddot(const double *v1, const double *v2); 00114 void vdadd(const double *src1, const double *src2, double *dst);
Copyright © 2008, Cycling '74