]> git.xonotic.org Git - xonotic/xonotic.git/blob - misc/builddeps/linux64/ode/include/ode/odemath_legacy.h
Remove builddeps: win32/gmp win64/gmp win32/sdl win64/sdl
[xonotic/xonotic.git] / misc / builddeps / linux64 / ode / include / ode / odemath_legacy.h
1 /*************************************************************************
2  *                                                                       *
3  * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith.       *
4  * All rights reserved.  Email: russ@q12.org   Web: www.q12.org          *
5  *                                                                       *
6  * This library is free software; you can redistribute it and/or         *
7  * modify it under the terms of EITHER:                                  *
8  *   (1) The GNU Lesser General Public License as published by the Free  *
9  *       Software Foundation; either version 2.1 of the License, or (at  *
10  *       your option) any later version. The text of the GNU Lesser      *
11  *       General Public License is included with this library in the     *
12  *       file LICENSE.TXT.                                               *
13  *   (2) The BSD-style license that is included with this library in     *
14  *       the file LICENSE-BSD.TXT.                                       *
15  *                                                                       *
16  * This library is distributed in the hope that it will be useful,       *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
19  * LICENSE.TXT and LICENSE-BSD.TXT for more details.                     *
20  *                                                                       *
21  *************************************************************************/
22
23 #ifndef _ODE_ODEMATH_LEGACY_H_
24 #define _ODE_ODEMATH_LEGACY_H_
25
26
27 /*
28  *      These macros are not used any more inside of ODE
29  *  They are kept for backward compatibility with external code that
30  *  might still be using them.
31  */
32
33 /*
34  * General purpose vector operations with other vectors or constants.
35  */
36
37 #define dOP(a,op,b,c) do { \
38   (a)[0] = ((b)[0]) op ((c)[0]); \
39   (a)[1] = ((b)[1]) op ((c)[1]); \
40   (a)[2] = ((b)[2]) op ((c)[2]); \
41 } while (0)
42 #define dOPC(a,op,b,c) do { \
43   (a)[0] = ((b)[0]) op (c); \
44   (a)[1] = ((b)[1]) op (c); \
45   (a)[2] = ((b)[2]) op (c); \
46 } while (0)
47 #define dOPE(a,op,b) do {\
48   (a)[0] op ((b)[0]); \
49   (a)[1] op ((b)[1]); \
50   (a)[2] op ((b)[2]); \
51 } while (0)
52 #define dOPEC(a,op,c) do { \
53   (a)[0] op (c); \
54   (a)[1] op (c); \
55   (a)[2] op (c); \
56 } while (0)
57
58 /* Define an equation with operators
59  * For example this function can be used to replace
60  * <PRE>
61  * for (int i=0; i<3; ++i)
62  *   a[i] += b[i] + c[i];
63  * </PRE>
64  */
65 #define dOPE2(a,op1,b,op2,c) do { \
66   (a)[0] op1 ((b)[0]) op2 ((c)[0]); \
67   (a)[1] op1 ((b)[1]) op2 ((c)[1]); \
68   (a)[2] op1 ((b)[2]) op2 ((c)[2]); \
69 } while (0)
70
71
72 #define dLENGTHSQUARED(a) dCalcVectorLengthSquare3(a)
73 #define dLENGTH(a) dCalcVectorLength3(a)
74 #define dDISTANCE(a, b) dCalcPointsDistance3(a, b)
75
76
77 #define dDOT(a, b) dCalcVectorDot3(a, b)
78 #define dDOT13(a, b) dCalcVectorDot3_13(a, b)
79 #define dDOT31(a, b) dCalcVectorDot3_31(a, b)
80 #define dDOT33(a, b) dCalcVectorDot3_33(a, b)
81 #define dDOT14(a, b) dCalcVectorDot3_14(a, b)
82 #define dDOT41(a, b) dCalcVectorDot3_41(a, b)
83 #define dDOT44(a, b) dCalcVectorDot3_44(a, b)
84
85
86 /*
87  * cross product, set a = b x c. dCROSSpqr means that elements of `a', `b'
88  * and `c' are spaced p, q and r indexes apart respectively.
89  * dCROSS() means dCROSS111. `op' is normally `=', but you can set it to
90  * +=, -= etc to get other effects.
91  */
92
93 #define dCROSS(a,op,b,c) \
94   do { \
95   (a)[0] op ((b)[1]*(c)[2] - (b)[2]*(c)[1]); \
96   (a)[1] op ((b)[2]*(c)[0] - (b)[0]*(c)[2]); \
97   (a)[2] op ((b)[0]*(c)[1] - (b)[1]*(c)[0]); \
98   } while(0)
99 #define dCROSSpqr(a,op,b,c,p,q,r) \
100   do { \
101   (a)[  0] op ((b)[  q]*(c)[2*r] - (b)[2*q]*(c)[  r]); \
102   (a)[  p] op ((b)[2*q]*(c)[  0] - (b)[  0]*(c)[2*r]); \
103   (a)[2*p] op ((b)[  0]*(c)[  r] - (b)[  q]*(c)[  0]); \
104   } while(0)
105 #define dCROSS114(a,op,b,c) dCROSSpqr(a,op,b,c,1,1,4)
106 #define dCROSS141(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,1)
107 #define dCROSS144(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,4)
108 #define dCROSS411(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,1)
109 #define dCROSS414(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,4)
110 #define dCROSS441(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,1)
111 #define dCROSS444(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,4)
112
113
114 /*
115 * set a 3x3 submatrix of A to a matrix such that submatrix(A)*b = a x b.
116 * A is stored by rows, and has `skip' elements per row. the matrix is
117 * assumed to be already zero, so this does not write zero elements!
118 * if (plus,minus) is (+,-) then a positive version will be written.
119 * if (plus,minus) is (-,+) then a negative version will be written.
120 */
121
122 #define dCROSSMAT(A,a,skip,plus,minus) \
123   do { \
124   (A)[1] = minus (a)[2]; \
125   (A)[2] = plus (a)[1]; \
126   (A)[(skip)+0] = plus (a)[2]; \
127   (A)[(skip)+2] = minus (a)[0]; \
128   (A)[2*(skip)+0] = minus (a)[1]; \
129   (A)[2*(skip)+1] = plus (a)[0]; \
130   } while(0)
131
132
133
134
135 /* 
136 Note: NEVER call any of these functions/macros with the same variable for A and C, 
137 it is not equivalent to A*=B.
138 */
139
140 #define dMULTIPLY0_331(A, B, C) dMultiply0_331(A, B, C)
141 #define dMULTIPLY1_331(A, B, C) dMultiply1_331(A, B, C)
142 #define dMULTIPLY0_133(A, B, C) dMultiply0_133(A, B, C)
143 #define dMULTIPLY0_333(A, B, C) dMultiply0_333(A, B, C)
144 #define dMULTIPLY1_333(A, B, C) dMultiply1_333(A, B, C)
145 #define dMULTIPLY2_333(A, B, C) dMultiply2_333(A, B, C)
146
147 #define dMULTIPLYADD0_331(A, B, C) dMultiplyAdd0_331(A, B, C)
148 #define dMULTIPLYADD1_331(A, B, C) dMultiplyAdd1_331(A, B, C)
149 #define dMULTIPLYADD0_133(A, B, C) dMultiplyAdd0_133(A, B, C)
150 #define dMULTIPLYADD0_333(A, B, C) dMultiplyAdd0_333(A, B, C)
151 #define dMULTIPLYADD1_333(A, B, C) dMultiplyAdd1_333(A, B, C)
152 #define dMULTIPLYADD2_333(A, B, C) dMultiplyAdd2_333(A, B, C)
153
154
155 /*
156  *      These macros are not used any more inside of ODE
157  *  They are kept for backward compatibility with external code that
158  *  might still be using them.
159  */
160
161
162 #endif /* #ifndef _ODE_ODEMATH_LEGACY_H_ */