38 #ifndef FCL_CCD_INTERVAL_MATRIX_INL_H 39 #define FCL_CCD_INTERVAL_MATRIX_INL_H 41 #include "fcl/math/motion/taylor_model/interval_matrix.h" 48 struct IMatrix3<double>;
52 IMatrix3<double> rotationConstrain(
const IMatrix3<double>& m);
56 IMatrix3<S>::IMatrix3() {}
60 IMatrix3<S>::IMatrix3(S v)
69 IMatrix3<S>::IMatrix3(
const Matrix3<S>& m)
71 v_[0].setValue(m.row(0)[0], m.row(0)[1], m.row(0)[2]);
72 v_[1].setValue(m.row(1)[0], m.row(1)[1], m.row(1)[2]);
73 v_[2].setValue(m.row(2)[0], m.row(2)[1], m.row(2)[2]);
78 IMatrix3<S>::IMatrix3(S m[3][3][2])
87 IMatrix3<S>::IMatrix3(S m[3][3])
96 IMatrix3<S>::IMatrix3(Interval<S> m[3][3])
100 v_[2].setValue(m[2]);
104 template <
typename S>
105 IMatrix3<S>::IMatrix3(
const IVector3<S>& v1,
const IVector3<S>& v2,
const IVector3<S>& v3)
113 template <
typename S>
114 void IMatrix3<S>::setIdentity()
116 v_[0].setValue(1, 0, 0);
117 v_[1].setValue(0, 1, 0);
118 v_[2].setValue(0, 0, 1);
122 template <
typename S>
123 IVector3<S> IMatrix3<S>::getColumn(
size_t i)
const 125 return IVector3<S>(v_[0][i], v_[1][i], v_[2][i]);
129 template <
typename S>
130 const IVector3<S>& IMatrix3<S>::getRow(
size_t i)
const 136 template <
typename S>
137 Vector3<S> IMatrix3<S>::getColumnLow(
size_t i)
const 139 return Vector3<S>(v_[0][i][0], v_[1][i][0], v_[2][i][0]);
143 template <
typename S>
144 Vector3<S> IMatrix3<S>::getRowLow(
size_t i)
const 146 return Vector3<S>(v_[i][0][0], v_[i][1][0], v_[i][2][0]);
150 template <
typename S>
151 Vector3<S> IMatrix3<S>::getColumnHigh(
size_t i)
const 153 return Vector3<S>(v_[0][i][1], v_[1][i][1], v_[2][i][1]);
157 template <
typename S>
158 Vector3<S> IMatrix3<S>::getRowHigh(
size_t i)
const 160 return Vector3<S>(v_[i][0][1], v_[i][1][1], v_[i][2][1]);
164 template <
typename S>
165 Matrix3<S> IMatrix3<S>::getLow()
const 168 m << v_[0][0][1], v_[0][1][1], v_[0][2][1],
169 v_[1][0][1], v_[1][1][1], v_[1][2][1],
170 v_[2][0][1], v_[2][1][1], v_[2][2][1];
175 template <
typename S>
176 Matrix3<S> IMatrix3<S>::getHigh()
const 179 m << v_[0][0][1], v_[0][1][1], v_[0][2][1],
180 v_[1][0][1], v_[1][1][1], v_[1][2][1],
181 v_[2][0][1], v_[2][1][1], v_[2][2][1];
186 template <
typename S>
187 const Interval<S>& IMatrix3<S>::operator ()(
size_t i,
size_t j)
const 193 template <
typename S>
194 Interval<S>& IMatrix3<S>::operator ()(
size_t i,
size_t j)
200 template <
typename S>
201 IMatrix3<S> IMatrix3<S>::operator * (
const Matrix3<S>& m)
const 203 return IMatrix3(IVector3<S>(v_[0].dot(m.col(0)), v_[0].dot(m.col(1)), v_[0].dot(m.col(2))),
204 IVector3<S>(v_[1].dot(m.col(0)), v_[1].dot(m.col(1)), v_[1].dot(m.col(2))),
205 IVector3<S>(v_[2].dot(m.col(0)), v_[2].dot(m.col(1)), v_[2].dot(m.col(2))));
209 template <
typename S>
210 IVector3<S> IMatrix3<S>::operator * (
const Vector3<S>& v)
const 212 return IVector3<S>(v_[0].dot(v), v_[1].dot(v), v_[2].dot(v));
216 template <
typename S>
217 IVector3<S> IMatrix3<S>::operator * (
const IVector3<S>& v)
const 219 return IVector3<S>(v_[0].dot(v), v_[1].dot(v), v_[2].dot(v));
223 template <
typename S>
224 IMatrix3<S> IMatrix3<S>::operator * (
const IMatrix3<S>& m)
const 226 const IVector3<S>& mc0 = m.getColumn(0);
227 const IVector3<S>& mc1 = m.getColumn(1);
228 const IVector3<S>& mc2 = m.getColumn(2);
230 return IMatrix3(IVector3<S>(v_[0].dot(mc0), v_[0].dot(mc1), v_[0].dot(mc2)),
231 IVector3<S>(v_[1].dot(mc0), v_[1].dot(mc1), v_[1].dot(mc2)),
232 IVector3<S>(v_[2].dot(mc0), v_[2].dot(mc1), v_[2].dot(mc2)));
236 template <
typename S>
237 IMatrix3<S>& IMatrix3<S>::operator *= (
const Matrix3<S>& m)
239 v_[0].setValue(v_[0].dot(m.col(0)), v_[0].dot(m.col(1)), v_[0].dot(m.col(2)));
240 v_[1].setValue(v_[1].dot(m.col(0)), v_[1].dot(m.col(1)), v_[1].dot(m.col(2)));
241 v_[2].setValue(v_[2].dot(m.col(0)), v_[2].dot(m.col(1)), v_[2].dot(m.col(2)));
246 template <
typename S>
247 IMatrix3<S>& IMatrix3<S>::operator *= (
const IMatrix3<S>& m)
249 const IVector3<S>& mc0 = m.getColumn(0);
250 const IVector3<S>& mc1 = m.getColumn(1);
251 const IVector3<S>& mc2 = m.getColumn(2);
253 v_[0].setValue(v_[0].dot(mc0), v_[0].dot(mc1), v_[0].dot(mc2));
254 v_[1].setValue(v_[1].dot(mc0), v_[1].dot(mc1), v_[1].dot(mc2));
255 v_[2].setValue(v_[2].dot(mc0), v_[2].dot(mc1), v_[2].dot(mc2));
260 template <
typename S>
261 IMatrix3<S> IMatrix3<S>::operator + (
const IMatrix3<S>& m)
const 263 return IMatrix3(v_[0] + m.v_[0], v_[1] + m.v_[1], v_[2] + m.v_[2]);
267 template <
typename S>
268 IMatrix3<S>& IMatrix3<S>::operator += (
const IMatrix3<S>& m)
277 template <
typename S>
278 IMatrix3<S> IMatrix3<S>::operator - (
const IMatrix3<S>& m)
const 280 return IMatrix3(v_[0] - m.v_[0], v_[1] - m.v_[1], v_[2] - m.v_[2]);
284 template <
typename S>
285 IMatrix3<S>& IMatrix3<S>::operator -= (
const IMatrix3<S>& m)
294 template <
typename S>
295 IMatrix3<S>& IMatrix3<S>::rotationConstrain()
297 for(std::size_t i = 0; i < 3; ++i)
299 for(std::size_t j = 0; j < 3; ++j)
301 if(v_[i][j][0] < -1) v_[i][j][0] = -1;
302 else if(v_[i][j][0] > 1) v_[i][j][0] = 1;
304 if(v_[i][j][1] < -1) v_[i][j][1] = -1;
305 else if(v_[i][j][1] > 1) v_[i][j][1] = 1;
313 template <
typename S>
314 void IMatrix3<S>::print()
const 316 std::cout <<
"[" << v_[0][0][0] <<
"," << v_[0][0][1] <<
"]" <<
" [" << v_[0][1][0] <<
"," << v_[0][1][1] <<
"]" <<
" [" << v_[0][2][0] <<
"," << v_[0][2][1] <<
"]" << std::endl;
317 std::cout <<
"[" << v_[1][0][0] <<
"," << v_[1][0][1] <<
"]" <<
" [" << v_[1][1][0] <<
"," << v_[1][1][1] <<
"]" <<
" [" << v_[1][2][0] <<
"," << v_[1][2][1] <<
"]" << std::endl;
318 std::cout <<
"[" << v_[2][0][0] <<
"," << v_[2][0][1] <<
"]" <<
" [" << v_[2][1][0] <<
"," << v_[2][1][1] <<
"]" <<
" [" << v_[2][2][0] <<
"," << v_[2][2][1] <<
"]" << std::endl;
322 template <
typename S>
323 IMatrix3<S> rotationConstrain(
const IMatrix3<S>& m)
326 for(std::size_t i = 0; i < 3; ++i)
328 for(std::size_t j = 0; j < 3; ++j)
330 if(m(i, j)[0] < -1) res(i, j)[0] = -1;
331 else if(m(i, j)[0] > 1) res(i, j)[0] = 1;
333 if(m(i, j)[1] < -1) res(i, j)[1] = -1;
334 else if(m(i, j)[1] > 1) res(i, j)[1] = 1;
Main namespace.
Definition: broadphase_bruteforce-inl.h:45