anim.h

Go to the documentation of this file.
00001 /*                          A N I M . H
00002  * BRL-CAD
00003  *
00004  * Copyright (c) 1993-2006 United States Government as represented by
00005  * the U.S. Army Research Laboratory.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this file; see the file named COPYING for more
00019  * information.
00020  */
00021 /** @addtogroup anim */
00022 /*@{*/
00023 /** @file anim.h
00024  *
00025  *  @author
00026  *      Carl J. Nuzman
00027  *
00028  * @par Source
00029  *      The U. S. Army Research Laboratory
00030  *@n      Aberdeen Proving Ground, Maryland  21005-5068  USA
00031  *
00032  *      Be sure to include vmath.h before this file.
00033  */
00034 
00035 #include "compat4.h"
00036 
00037 #define ANIM_STEER_NEW  0
00038 #define ANIM_STEER_END  1
00039 
00040 #define DTOR    M_PI/180.0
00041 #define RTOD    180.0/M_PI
00042 
00043 #define VSUBUNIT(a,b,c) {VSUB2(a,b,c);\
00044                         VUNITIZE(a);}
00045 #define FVSCAN(f,a)     fscanf(f,"%lf %lf %lf", (a),(a)+1,(a)+2)
00046 #define FMATSCAN(f,m)   {FVSCAN(f,(m)); FVSCAN(f,(m)+4);\
00047                          FVSCAN(f,(m)+8); FVSCAN(f,(m)+12);}
00048 #define VSCAN(a)        scanf("%lf %lf %lf", (a),(a)+1,(a)+2)
00049 #define VPRINTS(t,a)    printf("%s %f %f %f ",t,(a)[0],(a)[1],(a)[2])
00050 #define VPRINTN(t,a)    printf("%s %f %f %f\n",t,(a)[0],(a)[1],(a)[2])
00051 
00052 #define MAT_MOVE(m,n)   MAT_COPY(m,n)
00053 
00054 /***** 3x3 matrix format *****/
00055 
00056 typedef fastf_t  mat3_t[9];
00057 
00058 #define MAT3ZERO(m)     {\
00059         int _j; for(_j=0;_j<9;_j++) m[_j]=0.0;}
00060 
00061 #define MAT3IDN(m)      {\
00062         int _j; for(_j=0;_j<9;_j++) m[_j]=0.0;\
00063         m[0] = m[4] = m[8] = 1.0;}
00064 
00065 #define MAT3MUL(o,a,b)  {\
00066         (o)[0] = (a)[0]*(b)[0] + (a)[1]*(b)[3] + (a)[2]*(b)[6];\
00067         (o)[1] = (a)[0]*(b)[1] + (a)[1]*(b)[4] + (a)[2]*(b)[7];\
00068         (o)[2] = (a)[0]*(b)[2] + (a)[1]*(b)[5] + (a)[2]*(b)[8];\
00069         (o)[3] = (a)[3]*(b)[0] + (a)[4]*(b)[3] + (a)[5]*(b)[6];\
00070         (o)[4] = (a)[3]*(b)[1] + (a)[4]*(b)[4] + (a)[5]*(b)[7];\
00071         (o)[5] = (a)[3]*(b)[2] + (a)[4]*(b)[5] + (a)[5]*(b)[8];\
00072         (o)[6] = (a)[6]*(b)[0] + (a)[7]*(b)[3] + (a)[8]*(b)[6];\
00073         (o)[7] = (a)[6]*(b)[1] + (a)[7]*(b)[4] + (a)[8]*(b)[7];\
00074         (o)[8] = (a)[6]*(b)[2] + (a)[7]*(b)[5] + (a)[8]*(b)[8];}
00075 
00076 #define MAT3SUM(o,a,b)  {\
00077         int _j; for(_j=0;_j<9;_j++) (o)[_j]=(a)[_j]+(b)[_j];}
00078 
00079 #define MAT3DIF(o,a,b)  {\
00080         int _j; for(_j=0;_j<9;_j++) (o)[_j]=(a)[_j]-(b)[_j];}
00081 
00082 #define MAT3SCALE(o,a,s)        {\
00083         int _j; for(_j=0;_j<9;_j++) (o)[_j]=(a)[_j] * (s);}
00084 
00085 #define MAT3MOVE(o,a)   {\
00086         int _j; for(_j=0;_j<9;_j++) (o)[_j] = (a)[_j];}
00087 
00088 #define MAT3XVEC(u,m,v) {\
00089         (u)[0] = (m)[0]*(v)[0] + (m)[1]*(v)[1] + (m)[2]*(v)[2];\
00090         (u)[1] = (m)[3]*(v)[0] + (m)[4]*(v)[1] + (m)[5]*(v)[2];\
00091         (u)[2] = (m)[6]*(v)[0] + (m)[7]*(v)[1] + (m)[8]*(v)[2];}
00092 
00093 #define MAT3TO4(o,i)    {\
00094         (o)[0] = (i)[0];\
00095         (o)[1] = (i)[1];\
00096         (o)[2] = (i)[2];\
00097         (o)[4] = (i)[3];\
00098         (o)[5] = (i)[4];\
00099         (o)[6] = (i)[5];\
00100         (o)[8] = (i)[6];\
00101         (o)[9] = (i)[7];\
00102         (o)[10] = (i)[8];\
00103         (o)[3]=(o)[7]=(o)[11]=(o)[12]=(o)[13]=(o)[14]=0.0;\
00104         (o)[15]=1.0;}
00105 
00106 #define MAT4TO3(o,i)    {\
00107         (o)[0] = (i)[0];\
00108         (o)[1] = (i)[1];\
00109         (o)[2] = (i)[2];\
00110         (o)[3] = (i)[4];\
00111         (o)[4] = (i)[5];\
00112         (o)[5] = (i)[6];\
00113         (o)[6] = (i)[8];\
00114         (o)[7] = (i)[9];\
00115         (o)[8] = (i)[10];}
00116 
00117 
00118 /* tilde matrix: [M]a = v X a */
00119 #define MAKE_TILDE(m,v) {\
00120         MAT3ZERO(m);\
00121         m[1]= -v[2];    m[2]=v[1];      m[3]= v[2];\
00122         m[5]= -v[0];    m[6]= -v[1];    m[7]= v[0];}
00123 
00124 /* a = Ix Iy Iz    b = Ixy Ixz Iyz*/
00125 #define INERTIAL_MAT3(m,a,b)    {\
00126         (m)[0] =  (a)[0]; (m)[1] = -(b)[0]; (m)[2] = -(b)[1];\
00127         (m)[3] = -(b)[0]; (m)[4] =  (a)[1]; (m)[5] = -(b)[2];\
00128         (m)[6] = -(b)[1]; (m)[7] = -(b)[2]; (m)[8]=  (a)[2];}
00129 
00130 
00131 
00132 /*@}*/
00133 /*
00134  * Local Variables:
00135  * mode: C
00136  * tab-width: 8
00137  * c-basic-offset: 4
00138  * indent-tabs-mode: t
00139  * End:
00140  * ex: shiftwidth=4 tabstop=8
00141  */
00142 

Generated on Mon Sep 18 01:24:40 2006 for BRL-CAD by  doxygen 1.4.6