Open Dynamics Engine

odemath_legacy.h

00001 /*************************************************************************
00002  *                                                                       *
00003  * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith.       *
00004  * All rights reserved.  Email: russ@q12.org   Web: www.q12.org          *
00005  *                                                                       *
00006  * This library is free software; you can redistribute it and/or         *
00007  * modify it under the terms of EITHER:                                  *
00008  *   (1) The GNU Lesser General Public License as published by the Free  *
00009  *       Software Foundation; either version 2.1 of the License, or (at  *
00010  *       your option) any later version. The text of the GNU Lesser      *
00011  *       General Public License is included with this library in the     *
00012  *       file LICENSE.TXT.                                               *
00013  *   (2) The BSD-style license that is included with this library in     *
00014  *       the file LICENSE-BSD.TXT.                                       *
00015  *                                                                       *
00016  * This library is distributed in the hope that it will be useful,       *
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
00019  * LICENSE.TXT and LICENSE-BSD.TXT for more details.                     *
00020  *                                                                       *
00021  *************************************************************************/
00022 
00023 #ifndef _ODE_ODEMATH_LEGACY_H_
00024 #define _ODE_ODEMATH_LEGACY_H_
00025 
00026 
00032 /*
00033 *  These macros are not used any more inside of ODE
00034 *  They are kept for backward compatibility with external code that
00035 *  might still be using them.
00036 */
00042 
00043 /*
00044 * General purpose vector operations with other vectors or constants.
00045 */
00046 
00047 #define dOP(a,op,b,c) do { \
00048   (a)[0] = ((b)[0]) op ((c)[0]); \
00049   (a)[1] = ((b)[1]) op ((c)[1]); \
00050   (a)[2] = ((b)[2]) op ((c)[2]); \
00051 } while (0)
00052 #define dOPC(a,op,b,c) do { \
00053   (a)[0] = ((b)[0]) op (c); \
00054   (a)[1] = ((b)[1]) op (c); \
00055   (a)[2] = ((b)[2]) op (c); \
00056 } while (0)
00057 #define dOPE(a,op,b) do {\
00058   (a)[0] op ((b)[0]); \
00059   (a)[1] op ((b)[1]); \
00060   (a)[2] op ((b)[2]); \
00061 } while (0)
00062 #define dOPEC(a,op,c) do { \
00063   (a)[0] op (c); \
00064   (a)[1] op (c); \
00065   (a)[2] op (c); \
00066 } while (0)
00067 
00074 #define dOPE2(a,op1,b,op2,c) do { \
00075   (a)[0] op1 ((b)[0]) op2 ((c)[0]); \
00076   (a)[1] op1 ((b)[1]) op2 ((c)[1]); \
00077   (a)[2] op1 ((b)[2]) op2 ((c)[2]); \
00078 } while (0)
00079 
00080 
00081 #define dLENGTHSQUARED(a) dCalcVectorLengthSquare3(a)
00082 #define dLENGTH(a) dCalcVectorLength3(a)
00083 #define dDISTANCE(a, b) dCalcPointsDistance3(a, b)
00084 
00085 
00086 #define dDOT(a, b) dCalcVectorDot3(a, b)
00087 #define dDOT13(a, b) dCalcVectorDot3_13(a, b)
00088 #define dDOT31(a, b) dCalcVectorDot3_31(a, b)
00089 #define dDOT33(a, b) dCalcVectorDot3_33(a, b)
00090 #define dDOT14(a, b) dCalcVectorDot3_14(a, b)
00091 #define dDOT41(a, b) dCalcVectorDot3_41(a, b)
00092 #define dDOT44(a, b) dCalcVectorDot3_44(a, b)
00093 
00094 
00095 /*
00096 * cross product, set a = b x c. dCROSSpqr means that elements of `a', `b'
00097 * and `c' are spaced p, q and r indexes apart respectively.
00098 * dCROSS() means dCROSS111. `op' is normally `=', but you can set it to
00099 * +=, -= etc to get other effects.
00100 */
00101 
00102 #define dCROSS(a,op,b,c) \
00103   do { \
00104   (a)[0] op ((b)[1]*(c)[2] - (b)[2]*(c)[1]); \
00105   (a)[1] op ((b)[2]*(c)[0] - (b)[0]*(c)[2]); \
00106   (a)[2] op ((b)[0]*(c)[1] - (b)[1]*(c)[0]); \
00107   } while(0)
00108 #define dCROSSpqr(a,op,b,c,p,q,r) \
00109   do { \
00110   (a)[  0] op ((b)[  q]*(c)[2*r] - (b)[2*q]*(c)[  r]); \
00111   (a)[  p] op ((b)[2*q]*(c)[  0] - (b)[  0]*(c)[2*r]); \
00112   (a)[2*p] op ((b)[  0]*(c)[  r] - (b)[  q]*(c)[  0]); \
00113   } while(0)
00114 #define dCROSS114(a,op,b,c) dCROSSpqr(a,op,b,c,1,1,4)
00115 #define dCROSS141(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,1)
00116 #define dCROSS144(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,4)
00117 #define dCROSS411(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,1)
00118 #define dCROSS414(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,4)
00119 #define dCROSS441(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,1)
00120 #define dCROSS444(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,4)
00121 
00122 
00123 /*
00124 * set a 3x3 submatrix of A to a matrix such that submatrix(A)*b = a x b.
00125 * A is stored by rows, and has `skip' elements per row. the matrix is
00126 * assumed to be already zero, so this does not write zero elements!
00127 * if (plus,minus) is (+,-) then a positive version will be written.
00128 * if (plus,minus) is (-,+) then a negative version will be written.
00129 */
00130 
00131 #define dCROSSMAT(A,a,skip,plus,minus) \
00132   do { \
00133   (A)[1] = minus (a)[2]; \
00134   (A)[2] = plus (a)[1]; \
00135   (A)[(skip)+0] = plus (a)[2]; \
00136   (A)[(skip)+2] = minus (a)[0]; \
00137   (A)[2*(skip)+0] = minus (a)[1]; \
00138   (A)[2*(skip)+1] = plus (a)[0]; \
00139   } while(0)
00140 
00141 
00142 
00143 
00144 /* 
00145 Note: NEVER call any of these functions/macros with the same variable for A and C, 
00146 it is not equivalent to A*=B.
00147 */
00148 
00149 #define dMULTIPLY0_331(A, B, C) dMultiply0_331(A, B, C)
00150 #define dMULTIPLY1_331(A, B, C) dMultiply1_331(A, B, C)
00151 #define dMULTIPLY0_133(A, B, C) dMultiply0_133(A, B, C)
00152 #define dMULTIPLY0_333(A, B, C) dMultiply0_333(A, B, C)
00153 #define dMULTIPLY1_333(A, B, C) dMultiply1_333(A, B, C)
00154 #define dMULTIPLY2_333(A, B, C) dMultiply2_333(A, B, C)
00155 
00156 #define dMULTIPLYADD0_331(A, B, C) dMultiplyAdd0_331(A, B, C)
00157 #define dMULTIPLYADD1_331(A, B, C) dMultiplyAdd1_331(A, B, C)
00158 #define dMULTIPLYADD0_133(A, B, C) dMultiplyAdd0_133(A, B, C)
00159 #define dMULTIPLYADD0_333(A, B, C) dMultiplyAdd0_333(A, B, C)
00160 #define dMULTIPLYADD1_333(A, B, C) dMultiplyAdd1_333(A, B, C)
00161 #define dMULTIPLYADD2_333(A, B, C) dMultiplyAdd2_333(A, B, C)
00162 
00163 
00169 /*
00170 *  These macros are not used any more inside of ODE
00171 *  They are kept for backward compatibility with external code that
00172 *  might still be using them.
00173 */
00179 
00180 
00181 #endif // #ifndef _ODE_ODEMATH_LEGACY_H_