44 #ifndef __OPENCV_CORE_AFFINE3_HPP__
45 #define __OPENCV_CORE_AFFINE3_HPP__
114 template <
typename Y>
operator Affine3<Y>()
const;
120 #if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H
121 Affine3(
const Eigen::Transform<
T, 3, Eigen::Affine, (Eigen::RowMajor)>& affine);
122 Affine3(
const Eigen::Transform<T, 3, Eigen::Affine>& affine);
123 operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>()
const;
124 operator Eigen::Transform<T, 3, Eigen::Affine>()
const;
128 template<
typename T>
static
131 template<
typename T,
typename V>
static
162 template<
typename T>
inline
167 template<
typename T>
inline
172 template<
typename T>
inline
181 template<
typename T>
inline
190 template<
typename T>
inline
195 if (data.
cols == 4 && data.
rows == 4)
200 else if (data.
cols == 4 && data.
rows == 3)
203 translation(
data(
Rect(3, 0, 1, 3)));
213 template<
typename T>
inline
217 template<
typename T>
inline
223 template<
typename T>
inline
229 template<
typename T>
inline
232 double rx = _rvec[0], ry = _rvec[1], rz = _rvec[2];
235 if (theta < DBL_EPSILON)
236 rotation(Mat3::eye());
239 const double I[] = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
241 double c = std::cos(theta);
242 double s = std::sin(theta);
244 double itheta = theta ? 1./theta : 0.;
246 rx *= itheta; ry *= itheta; rz *= itheta;
248 double rrt[] = { rx*rx, rx*ry, rx*rz, rx*ry, ry*ry, ry*rz, rx*rz, ry*rz, rz*rz };
249 double _r_x_[] = { 0, -rz, ry, rz, 0, -rx, -ry, rx, 0 };
254 for(
int k = 0;
k < 9; ++
k)
255 R.
val[
k] = static_cast<float_type>(c*I[
k] + c1*rrt[
k] + s*_r_x_[
k]);
262 template<
typename T>
inline
267 if (data.
cols == 3 && data.
rows == 3)
273 else if ((data.
cols == 3 && data.
rows == 1) || (data.
cols == 1 && data.
rows == 3))
280 CV_Assert(!
"Input marix can be 3x3, 1x3 or 3x1");
283 template<
typename T>
inline
291 template<
typename T>
inline
297 template<
typename T>
inline
303 template<
typename T>
inline
313 template<
typename T>
inline
319 template<
typename T>
inline
327 double rx = R.
val[7] - R.
val[5];
328 double ry = R.
val[2] - R.
val[6];
329 double rz = R.
val[3] - R.
val[1];
331 double s =
std::sqrt((rx*rx + ry*ry + rz*rz)*0.25);
332 double c = (R.
val[0] + R.
val[4] + R.
val[8] - 1) * 0.5;
333 c = c > 1.0 ? 1.0 : c < -1.0 ? -1.0 :
c;
334 double theta = acos(c);
343 t = (R.
val[0] + 1) * 0.5;
345 t = (R.
val[4] + 1) * 0.5;
346 ry =
std::sqrt(std::max(t, 0.0)) * (R.
val[1] < 0 ? -1.0 : 1.0);
347 t = (R.
val[8] + 1) * 0.5;
348 rz =
std::sqrt(std::max(t, 0.0)) * (R.
val[2] < 0 ? -1.0 : 1.0);
350 if( fabs(rx) < fabs(ry) && fabs(rx) < fabs(rz) && (R.
val[5] > 0) != (ry*rz > 0) )
352 theta /=
std::sqrt(rx*rx + ry*ry + rz*rz);
360 double vth = 1/(2*s);
362 rx *= vth; ry *= vth; rz *= vth;
368 template<
typename T>
inline
374 template<
typename T>
inline
380 result.
val[12] = result.
val[13] = result.
val[14] = 0;
383 for(
int j = 0; j < 3; ++j)
385 for(
int i = 0; i < 3; ++i)
388 for(
int k = 0;
k < 3; ++
k)
389 value +=
R(j,
k) * Lc(
k, i);
398 template<
typename T>
inline
404 template<
typename T>
inline
414 template<
typename T>
inline
420 template<
typename T>
template <
typename Y>
inline
426 template<
typename T>
template <
typename Y>
inline
432 template<
typename T>
inline
438 template<
typename T,
typename V>
inline
441 const typename Affine3<T>::Mat4&
m = affine.
matrix;
444 r.
x = m.val[0] * v.x + m.val[1] * v.y + m.val[ 2] * v.z + m.val[ 3];
445 r.y = m.val[4] * v.x + m.val[5] * v.y + m.val[ 6] * v.z + m.val[ 7];
446 r.z = m.val[8] * v.x + m.val[9] * v.y + m.val[10] * v.z + m.val[11];
455 r.
val[0] = m.
val[0] * v[0] + m.
val[1] * v[1] + m.
val[ 2] * v[2] + m.
val[ 3];
456 r.
val[1] = m.
val[4] * v[0] + m.
val[5] * v[1] + m.
val[ 6] * v[2] + m.
val[ 7];
457 r.
val[2] = m.
val[8] * v[0] + m.
val[9] * v[1] + m.
val[10] * v[2] + m.
val[11];
466 r.
val[0] = m.
val[0] * v[0] + m.
val[1] * v[1] + m.
val[ 2] * v[2] + m.
val[ 3];
467 r.
val[1] = m.
val[4] * v[0] + m.
val[5] * v[1] + m.
val[ 6] * v[2] + m.
val[ 7];
468 r.
val[2] = m.
val[8] * v[0] + m.
val[9] * v[1] + m.
val[10] * v[2] + m.
val[11];
474 #if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H
476 template<
typename T>
inline
482 template<
typename T>
inline
485 Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>
a = affine;
489 template<
typename T>
inline
492 Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>
r;
498 template<
typename T>
inline
501 return this->
operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>();
CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst)
computes square root of each matrix element (dst = src**0.5)
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions ...
Definition: core.hpp:1962
Affine3 translate(const Vec3 &t) const
Definition: affine.hpp:405
Mat reshape(int cn, int rows=0) const
creates alternative matrix header for the same data, with different
Affine3< _Tp > value_type
Definition: affine.hpp:143
Affine3< double > Affine3d
Definition: affine.hpp:135
Definition: core.hpp:1013
int CvScalar value
Definition: core_c.h:340
A short numerical vector.
Definition: core.hpp:84
Definition: core.hpp:2499
Mat4 matrix
Definition: affine.hpp:118
void copyTo(OutputArray m) const
copies the matrix content to "m".
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: core_c.h:403
CvRect r
Definition: core_c.h:1282
const CvMat const CvMat const CvMat CvMat CvMat CvMat CvMat CvSize CvMat CvMat * T
Definition: calib3d.hpp:270
_Tp channel_type
Definition: affine.hpp:145
Vec< float_type, 3 > Vec3
Definition: affine.hpp:60
Affine3< float > Affine3f
Definition: affine.hpp:134
Affine3 concatenate(const Affine3 &affine) const
Definition: affine.hpp:415
const CvPoint2D32f double matrix[3][3]
Definition: legacy.hpp:1070
const CvArr CvArr int method
Definition: imgproc_c.h:281
ColorT< T > operator*(Y s, const ColorT< T > &c)
const CvArr const CvArr CvArr * result
Definition: core_c.h:805
Matx< _Tp, 1, n > row(int i) const
extract the matrix row
Definition: operations.hpp:427
int cols
Definition: core.hpp:1962
Vec3 translation() const
Definition: affine.hpp:314
int type() const
returns element type, similar to CV_MAT_TYPE(cvmat->type)
Definition: mat.hpp:399
Definition: core.hpp:1013
T float_type
Definition: affine.hpp:57
Definition: core.hpp:2499
Vec< double, 3 > Vec3d
Definition: core.hpp:684
static Vec all(_Tp alpha)
Definition: operations.hpp:1210
Mat3 rotation() const
Definition: affine.hpp:298
const CvMat const CvMat const CvMat CvMat CvMat CvMat CvMat CvSize CvMat * R
Definition: calib3d.hpp:270
Vec3 rvec() const
Definition: affine.hpp:320
Vec< channel_type, channels > vec_type
Definition: affine.hpp:154
const CvMat CvMat CvMat int k
Definition: legacy.hpp:3052
Affine3 inv(int method=cv::DECOMP_SVD) const
Definition: affine.hpp:369
CvPoint2D32f float float float c
Definition: legacy.hpp:578
Informative template class for OpenCV "scalars".
Definition: core.hpp:1006
void int double double theta
Definition: imgproc_c.h:603
void * data
Definition: core_c.h:206
The n-dimensional matrix class.
Definition: core.hpp:1688
static void compute(InputArray src, OutputArray w, OutputArray u, OutputArray vt, int flags=0)
decomposes matrix and stores the results to user-provided matrices
static Affine3 Identity()
Definition: affine.hpp:218
const CvArr const CvArr * V
Definition: core_c.h:733
GLsizei const GLfloat * value
Definition: core_c.h:341
void rotation(const Mat3 &R)
Definition: affine.hpp:224
_Tp val[m *n]
Definition: core.hpp:544
GLuint GLuint GLsizei GLenum type
Definition: core_c.h:114
const GLubyte * c
Definition: legacy.hpp:633
Definition: core.hpp:1013
GLboolean GLboolean GLboolean GLboolean a
Definition: legacy.hpp:633
Definition: affine.hpp:54
Matx< float_type, 4, 4 > Mat4
Definition: affine.hpp:59
Affine3()
Implementaiton.
Definition: affine.hpp:163
GLubyte GLubyte GLubyte GLubyte w
Affine3 rotate(const Mat3 &R) const
Definition: affine.hpp:375
Matx< float_type, 3, 3 > Mat3
Definition: affine.hpp:58
int x
Definition: types_c.h:953
GLint GLint GLsizei GLsizei GLsizei depth
Definition: core_c.h:76
Mat3 linear() const
Definition: affine.hpp:304
void translate(const Vec2f &pos)
CV_EXPORTS void rotate(const GpuMat &src, GpuMat &dst, Size dsize, double angle, double xShift=0, double yShift=0, int interpolation=INTER_LINEAR, Stream &stream=Stream::Null())
Affine3< typename DataType< _Tp >::work_type > work_type
Definition: affine.hpp:144
Rect_< int > Rect
Definition: core.hpp:897
void translation(const Vec3 &t)
Definition: affine.hpp:292
Matx< _Tp, n, m > t() const
transpose the matrix
Definition: operations.hpp:777
Affine3< Y > cast() const