Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef PQP_OBB_DISJOINT
00042 #define PQP_OBB_DISJOINT
00043
00044 #include "MatVec.h"
00045 #include "PQP_Compile.h"
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 inline
00061 int
00062 obb_disjoint(PQP_REAL B[3][3], PQP_REAL T[3], PQP_REAL a[3], PQP_REAL b[3])
00063 {
00064 register PQP_REAL t, s;
00065 register int r;
00066 PQP_REAL Bf[3][3];
00067 const PQP_REAL reps = (PQP_REAL)1e-6;
00068
00069
00070 Bf[0][0] = myfabs(B[0][0]); Bf[0][0] += reps;
00071 Bf[0][1] = myfabs(B[0][1]); Bf[0][1] += reps;
00072 Bf[0][2] = myfabs(B[0][2]); Bf[0][2] += reps;
00073 Bf[1][0] = myfabs(B[1][0]); Bf[1][0] += reps;
00074 Bf[1][1] = myfabs(B[1][1]); Bf[1][1] += reps;
00075 Bf[1][2] = myfabs(B[1][2]); Bf[1][2] += reps;
00076 Bf[2][0] = myfabs(B[2][0]); Bf[2][0] += reps;
00077 Bf[2][1] = myfabs(B[2][1]); Bf[2][1] += reps;
00078 Bf[2][2] = myfabs(B[2][2]); Bf[2][2] += reps;
00079
00080
00081 r = 1;
00082
00083
00084 t = myfabs(T[0]);
00085
00086 r &= (t <=
00087 (a[0] + b[0] * Bf[0][0] + b[1] * Bf[0][1] + b[2] * Bf[0][2]));
00088 if (!r) return 1;
00089
00090
00091 s = T[0]*B[0][0] + T[1]*B[1][0] + T[2]*B[2][0];
00092 t = myfabs(s);
00093
00094 r &= ( t <=
00095 (b[0] + a[0] * Bf[0][0] + a[1] * Bf[1][0] + a[2] * Bf[2][0]));
00096 if (!r) return 2;
00097
00098
00099 t = myfabs(T[1]);
00100
00101 r &= ( t <=
00102 (a[1] + b[0] * Bf[1][0] + b[1] * Bf[1][1] + b[2] * Bf[1][2]));
00103 if (!r) return 3;
00104
00105
00106 t = myfabs(T[2]);
00107
00108 r &= ( t <=
00109 (a[2] + b[0] * Bf[2][0] + b[1] * Bf[2][1] + b[2] * Bf[2][2]));
00110 if (!r) return 4;
00111
00112
00113 s = T[0]*B[0][1] + T[1]*B[1][1] + T[2]*B[2][1];
00114 t = myfabs(s);
00115
00116 r &= ( t <=
00117 (b[1] + a[0] * Bf[0][1] + a[1] * Bf[1][1] + a[2] * Bf[2][1]));
00118 if (!r) return 5;
00119
00120
00121 s = T[0]*B[0][2] + T[1]*B[1][2] + T[2]*B[2][2];
00122 t = myfabs(s);
00123
00124 r &= ( t <=
00125 (b[2] + a[0] * Bf[0][2] + a[1] * Bf[1][2] + a[2] * Bf[2][2]));
00126 if (!r) return 6;
00127
00128
00129 s = T[2] * B[1][0] - T[1] * B[2][0];
00130 t = myfabs(s);
00131
00132 r &= ( t <=
00133 (a[1] * Bf[2][0] + a[2] * Bf[1][0] +
00134 b[1] * Bf[0][2] + b[2] * Bf[0][1]));
00135 if (!r) return 7;
00136
00137
00138 s = T[2] * B[1][1] - T[1] * B[2][1];
00139 t = myfabs(s);
00140
00141 r &= ( t <=
00142 (a[1] * Bf[2][1] + a[2] * Bf[1][1] +
00143 b[0] * Bf[0][2] + b[2] * Bf[0][0]));
00144 if (!r) return 8;
00145
00146
00147 s = T[2] * B[1][2] - T[1] * B[2][2];
00148 t = myfabs(s);
00149
00150 r &= ( t <=
00151 (a[1] * Bf[2][2] + a[2] * Bf[1][2] +
00152 b[0] * Bf[0][1] + b[1] * Bf[0][0]));
00153 if (!r) return 9;
00154
00155
00156 s = T[0] * B[2][0] - T[2] * B[0][0];
00157 t = myfabs(s);
00158
00159 r &= ( t <=
00160 (a[0] * Bf[2][0] + a[2] * Bf[0][0] +
00161 b[1] * Bf[1][2] + b[2] * Bf[1][1]));
00162 if (!r) return 10;
00163
00164
00165 s = T[0] * B[2][1] - T[2] * B[0][1];
00166 t = myfabs(s);
00167
00168 r &= ( t <=
00169 (a[0] * Bf[2][1] + a[2] * Bf[0][1] +
00170 b[0] * Bf[1][2] + b[2] * Bf[1][0]));
00171 if (!r) return 11;
00172
00173
00174 s = T[0] * B[2][2] - T[2] * B[0][2];
00175 t = myfabs(s);
00176
00177 r &= (t <=
00178 (a[0] * Bf[2][2] + a[2] * Bf[0][2] +
00179 b[0] * Bf[1][1] + b[1] * Bf[1][0]));
00180 if (!r) return 12;
00181
00182
00183 s = T[1] * B[0][0] - T[0] * B[1][0];
00184 t = myfabs(s);
00185
00186 r &= (t <=
00187 (a[0] * Bf[1][0] + a[1] * Bf[0][0] +
00188 b[1] * Bf[2][2] + b[2] * Bf[2][1]));
00189 if (!r) return 13;
00190
00191
00192 s = T[1] * B[0][1] - T[0] * B[1][1];
00193 t = myfabs(s);
00194
00195 r &= ( t <=
00196 (a[0] * Bf[1][1] + a[1] * Bf[0][1] +
00197 b[0] * Bf[2][2] + b[2] * Bf[2][0]));
00198 if (!r) return 14;
00199
00200
00201 s = T[1] * B[0][2] - T[0] * B[1][2];
00202 t = myfabs(s);
00203
00204 r &= ( t <=
00205 (a[0] * Bf[1][2] + a[1] * Bf[0][2] +
00206 b[0] * Bf[2][1] + b[1] * Bf[2][0]));
00207 if (!r) return 15;
00208
00209 return 0;
00210 }
00211
00212 #endif
00213
00214
00215
00216