38 #ifndef FCL_CCD_TAYLOR_MATRIX_INL_H 39 #define FCL_CCD_TAYLOR_MATRIX_INL_H 41 #include "fcl/math/motion/taylor_model/taylor_matrix.h" 48 class TMatrix3<double>;
52 TMatrix3<double> rotationConstrain(
const TMatrix3<double>& m);
56 TMatrix3<double> operator * (
const Matrix3<double>& m,
const TaylorModel<double>& a);
60 TMatrix3<double> operator * (
const TaylorModel<double>& a,
const Matrix3<double>& m);
64 TMatrix3<double> operator * (
const TaylorModel<double>& a,
const TMatrix3<double>& m);
68 TMatrix3<double> operator * (
double d,
const TMatrix3<double>& m);
72 TMatrix3<double> operator + (
const Matrix3<double>& m1,
const TMatrix3<double>& m2);
76 TMatrix3<double> operator - (
const Matrix3<double>& m1,
const TMatrix3<double>& m2);
80 TMatrix3<S>::TMatrix3()
87 TMatrix3<S>::TMatrix3(
const std::shared_ptr<TimeInterval<S>>& time_interval)
89 setTimeInterval(time_interval);
94 TMatrix3<S>::TMatrix3(TaylorModel<S> m[3][3])
96 v_[0] = TVector3<S>(m[0]);
97 v_[1] = TVector3<S>(m[1]);
98 v_[2] = TVector3<S>(m[2]);
102 template <
typename S>
103 TMatrix3<S>::TMatrix3(
const TVector3<S>& v1,
const TVector3<S>& v2,
const TVector3<S>& v3)
111 template <
typename S>
112 TMatrix3<S>::TMatrix3(
const Matrix3<S>& m,
const std::shared_ptr<TimeInterval<S>>& time_interval)
114 v_[0] = TVector3<S>(m.row(0), time_interval);
115 v_[1] = TVector3<S>(m.row(1), time_interval);
116 v_[2] = TVector3<S>(m.row(2), time_interval);
120 template <
typename S>
121 void TMatrix3<S>::setIdentity()
124 v_[0][0].coeff(0) = 1;
125 v_[1][1].coeff(0) = 1;
126 v_[2][2].coeff(0) = 1;
131 template <
typename S>
132 void TMatrix3<S>::setZero()
140 template <
typename S>
141 TVector3<S> TMatrix3<S>::getColumn(
size_t i)
const 143 return TVector3<S>(v_[0][i], v_[1][i], v_[2][i]);
147 template <
typename S>
148 const TVector3<S>& TMatrix3<S>::getRow(
size_t i)
const 154 template <
typename S>
155 const TaylorModel<S>& TMatrix3<S>::operator () (
size_t i,
size_t j)
const 161 template <
typename S>
162 TaylorModel<S>& TMatrix3<S>::operator () (
size_t i,
size_t j)
168 template <
typename S>
169 TMatrix3<S> TMatrix3<S>::operator * (
const Matrix3<S>& m)
const 171 const Vector3<S>& mc0 = m.col(0);
172 const Vector3<S>& mc1 = m.col(1);
173 const Vector3<S>& mc2 = m.col(2);
175 return TMatrix3(TVector3<S>(v_[0].dot(mc0), v_[0].dot(mc1), v_[0].dot(mc2)),
176 TVector3<S>(v_[1].dot(mc0), v_[1].dot(mc1), v_[1].dot(mc2)),
177 TVector3<S>(v_[2].dot(mc0), v_[2].dot(mc1), v_[2].dot(mc2)));
181 template <
typename S>
182 TVector3<S> TMatrix3<S>::operator * (
const Vector3<S>& v)
const 184 return TVector3<S>(v_[0].dot(v), v_[1].dot(v), v_[2].dot(v));
188 template <
typename S>
189 TVector3<S> TMatrix3<S>::operator * (
const TVector3<S>& v)
const 191 return TVector3<S>(v_[0].dot(v), v_[1].dot(v), v_[2].dot(v));
195 template <
typename S>
196 TMatrix3<S> TMatrix3<S>::operator * (
const TMatrix3<S>& m)
const 198 const TVector3<S>& mc0 = m.getColumn(0);
199 const TVector3<S>& mc1 = m.getColumn(1);
200 const TVector3<S>& mc2 = m.getColumn(2);
202 return TMatrix3(TVector3<S>(v_[0].dot(mc0), v_[0].dot(mc1), v_[0].dot(mc2)),
203 TVector3<S>(v_[1].dot(mc0), v_[1].dot(mc1), v_[1].dot(mc2)),
204 TVector3<S>(v_[2].dot(mc0), v_[2].dot(mc1), v_[2].dot(mc2)));
208 template <
typename S>
209 TMatrix3<S> TMatrix3<S>::operator * (
const TaylorModel<S>& d)
const 211 return TMatrix3(v_[0] * d, v_[1] * d, v_[2] * d);
215 template <
typename S>
216 TMatrix3<S> TMatrix3<S>::operator * (S d)
const 218 return TMatrix3(v_[0] * d, v_[1] * d, v_[2] * d);
222 template <
typename S>
223 TMatrix3<S>& TMatrix3<S>::operator *= (
const Matrix3<S>& m)
225 const Vector3<S>& mc0 = m.col(0);
226 const Vector3<S>& mc1 = m.col(1);
227 const Vector3<S>& mc2 = m.col(2);
229 v_[0] = TVector3<S>(v_[0].dot(mc0), v_[0].dot(mc1), v_[0].dot(mc2));
230 v_[1] = TVector3<S>(v_[1].dot(mc0), v_[1].dot(mc1), v_[1].dot(mc2));
231 v_[2] = TVector3<S>(v_[2].dot(mc0), v_[2].dot(mc1), v_[2].dot(mc2));
236 template <
typename S>
237 TMatrix3<S>& TMatrix3<S>::operator *= (
const TMatrix3<S>& m)
239 const TVector3<S>& mc0 = m.getColumn(0);
240 const TVector3<S>& mc1 = m.getColumn(1);
241 const TVector3<S>& mc2 = m.getColumn(2);
243 v_[0] = TVector3<S>(v_[0].dot(mc0), v_[0].dot(mc1), v_[0].dot(mc2));
244 v_[1] = TVector3<S>(v_[1].dot(mc0), v_[1].dot(mc1), v_[1].dot(mc2));
245 v_[2] = TVector3<S>(v_[2].dot(mc0), v_[2].dot(mc1), v_[2].dot(mc2));
251 template <
typename S>
252 TMatrix3<S>& TMatrix3<S>::operator *= (
const TaylorModel<S>& d)
261 template <
typename S>
262 TMatrix3<S>& TMatrix3<S>::operator *= (S d)
271 template <
typename S>
272 TMatrix3<S> TMatrix3<S>::operator + (
const TMatrix3<S>& m)
const 274 return TMatrix3(v_[0] + m.v_[0], v_[1] + m.v_[1], v_[2] + m.v_[2]);
278 template <
typename S>
279 TMatrix3<S>& TMatrix3<S>::operator += (
const TMatrix3<S>& m)
288 template <
typename S>
289 TMatrix3<S> TMatrix3<S>::operator + (
const Matrix3<S>& m)
const 291 TMatrix3 res = *
this;
297 template <
typename S>
298 TMatrix3<S>& TMatrix3<S>::operator += (
const Matrix3<S>& m)
300 for(std::size_t i = 0; i < 3; ++i)
302 for(std::size_t j = 0; j < 3; ++j)
310 template <
typename S>
311 TMatrix3<S> TMatrix3<S>::operator - (
const TMatrix3<S>& m)
const 313 return TMatrix3(v_[0] - m.v_[0], v_[1] - m.v_[1], v_[2] - m.v_[2]);
317 template <
typename S>
318 TMatrix3<S>& TMatrix3<S>::operator -= (
const TMatrix3<S>& m)
327 template <
typename S>
328 TMatrix3<S> TMatrix3<S>::operator - (
const Matrix3<S>& m)
const 330 TMatrix3 res = *
this;
336 template <
typename S>
337 TMatrix3<S>& TMatrix3<S>::operator -= (
const Matrix3<S>& m)
339 for(std::size_t i = 0; i < 3; ++i)
341 for(std::size_t j = 0; j < 3; ++j)
349 template <
typename S>
350 TMatrix3<S> TMatrix3<S>::operator - ()
const 352 return TMatrix3<S>(-v_[0], -v_[1], -v_[2]);
356 template <
typename S>
357 void TMatrix3<S>::print()
const 359 getColumn(0).print();
360 getColumn(1).print();
361 getColumn(2).print();
365 template <
typename S>
366 IMatrix3<S> TMatrix3<S>::getBound()
const 368 return IMatrix3<S>(v_[0].getBound(), v_[1].getBound(), v_[2].getBound());
372 template <
typename S>
373 IMatrix3<S> TMatrix3<S>::getBound(S l, S r)
const 375 return IMatrix3<S>(v_[0].getBound(l, r), v_[1].getBound(l, r), v_[2].getBound(l, r));
379 template <
typename S>
380 IMatrix3<S> TMatrix3<S>::getBound(S t)
const 382 return IMatrix3<S>(v_[0].getBound(t), v_[1].getBound(t), v_[2].getBound(t));
386 template <
typename S>
387 IMatrix3<S> TMatrix3<S>::getTightBound()
const 389 return IMatrix3<S>(v_[0].getTightBound(), v_[1].getTightBound(), v_[2].getTightBound());
393 template <
typename S>
394 IMatrix3<S> TMatrix3<S>::getTightBound(S l, S r)
const 396 return IMatrix3<S>(v_[0].getTightBound(l, r), v_[1].getTightBound(l, r), v_[2].getTightBound(l, r));
400 template <
typename S>
401 S TMatrix3<S>::diameter()
const 405 S tmp = v_[0][0].remainder().diameter();
407 tmp = v_[0][1].remainder().diameter();
409 tmp = v_[0][2].remainder().diameter();
412 tmp = v_[1][0].remainder().diameter();
414 tmp = v_[1][1].remainder().diameter();
416 tmp = v_[1][2].remainder().diameter();
419 tmp = v_[2][0].remainder().diameter();
421 tmp = v_[2][1].remainder().diameter();
423 tmp = v_[2][2].remainder().diameter();
430 template <
typename S>
431 void TMatrix3<S>::setTimeInterval(
const std::shared_ptr<TimeInterval<S>>& time_interval)
433 v_[0].setTimeInterval(time_interval);
434 v_[1].setTimeInterval(time_interval);
435 v_[2].setTimeInterval(time_interval);
439 template <
typename S>
440 void TMatrix3<S>::setTimeInterval(S l, S r)
442 v_[0].setTimeInterval(l, r);
443 v_[1].setTimeInterval(l, r);
444 v_[2].setTimeInterval(l, r);
448 template <
typename S>
449 const std::shared_ptr<TimeInterval<S>>& TMatrix3<S>::getTimeInterval()
const 451 return v_[0].getTimeInterval();
455 template <
typename S>
456 TMatrix3<S>& TMatrix3<S>::rotationConstrain()
458 for(std::size_t i = 0; i < 3; ++i)
460 for(std::size_t j = 0; j < 3; ++j)
462 if(v_[i][j].remainder()[0] < -1) v_[i][j].remainder()[0] = -1;
463 else if(v_[i][j].remainder()[0] > 1) v_[i][j].remainder()[0] = 1;
465 if(v_[i][j].remainder()[1] < -1) v_[i][j].remainder()[1] = -1;
466 else if(v_[i][j].remainder()[1] > 1) v_[i][j].remainder()[1] = 1;
468 if((v_[i][j].remainder()[0] == -1) && (v_[i][j].remainder()[1] == 1))
470 v_[i][j].coeff(0) = 0;
471 v_[i][j].coeff(1) = 0;
472 v_[i][j].coeff(2) = 0;
473 v_[i][j].coeff(3) = 0;
482 template <
typename S>
483 TMatrix3<S> rotationConstrain(
const TMatrix3<S>& m)
487 for(std::size_t i = 0; i < 3; ++i)
489 for(std::size_t j = 0; j < 3; ++j)
491 if(m(i, j).remainder()[0] < -1) res(i, j).remainder()[0] = -1;
492 else if(m(i, j).remainder()[0] > 1) res(i, j).remainder()[0] = 1;
494 if(m(i, j).remainder()[1] < -1) res(i, j).remainder()[1] = -1;
495 else if(m(i, j).remainder()[1] > 1) res(i, j).remainder()[1] = 1;
497 if((m(i, j).remainder()[0] == -1) && (m(i, j).remainder()[1] == 1))
499 res(i, j).coeff(0) = 0;
500 res(i, j).coeff(1) = 0;
501 res(i, j).coeff(2) = 0;
502 res(i, j).coeff(3) = 0;
511 template <
typename S>
512 TMatrix3<S> operator * (
const Matrix3<S>& m,
const TaylorModel<S>& a)
514 TMatrix3<S> res(a.getTimeInterval());
515 res(0, 0) = a * m(0, 0);
516 res(0, 1) = a * m(0, 1);
517 res(0, 1) = a * m(0, 2);
519 res(1, 0) = a * m(1, 0);
520 res(1, 1) = a * m(1, 1);
521 res(1, 1) = a * m(1, 2);
523 res(2, 0) = a * m(2, 0);
524 res(2, 1) = a * m(2, 1);
525 res(2, 1) = a * m(2, 2);
531 template <
typename S>
532 TMatrix3<S> operator * (
const TaylorModel<S>& a,
const Matrix3<S>& m)
538 template <
typename S>
539 TMatrix3<S> operator * (
const TaylorModel<S>& a,
const TMatrix3<S>& m)
545 template <
typename S>
546 TMatrix3<S> operator * (S d,
const TMatrix3<S>& m)
552 template <
typename S>
553 TMatrix3<S> operator + (
const Matrix3<S>& m1,
const TMatrix3<S>& m2)
559 template <
typename S>
560 TMatrix3<S> operator - (
const Matrix3<S>& m1,
const TMatrix3<S>& m2)
Main namespace.
Definition: broadphase_bruteforce-inl.h:45