GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — code/Chapter3_MarkerlessAR/src/GeometryTypes.cpp at master · bigjun/code Expand file tree/ Copy pathGeometryTypes.cppMore file actions executable file ·147 lines (115 loc) · 2.76 KB / Copy pathGeometryTypes.cppFile metadata and controlsexecutable file ·147 lines (115 loc) · 2.76 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 /***************************************************************************** * Markerless AR desktop application. ****************************************************************************** * by Khvedchenia Ievgen, 5th Dec 2012 * http://computer-vision-talks.com ****************************************************************************** * Ch3 of the book "Mastering OpenCV with Practical Computer Vision Projects" * Copyright Packt Publishing 2012. * http://www.packtpub.com/cool-projects-with-opencv/book *****************************************************************************/ //////////////////////////////////////////////////////////////////// // File includes: #include "GeometryTypes.hpp" Matrix44 Matrix44::getTransposed() const { Matrix44 t; for (int i=0;i<4; i++) for (int j=0;j<4;j++) t.mat[i][j] = mat[j][i]; return t; } Matrix44 Matrix44::identity() { Matrix44 eye; for (int i=0;i<4; i++) for (int j=0;j<4;j++) eye.mat[i][j] = i == j ? 1 : 0; return eye; } Matrix44 Matrix44::getInvertedRT() const { Matrix44 t = identity(); for (int col=0;col<3; col++) { for (int row=0;row<3;row++) { // Transpose rotation component (inversion) t.mat[row][col] = mat[col][row]; } // Inverse translation component t.mat[3][col] = - mat[3][col]; } return t; } Matrix33 Matrix33::identity() { Matrix33 eye; for (int i=0;i<3; i++) for (int j=0;j<3;j++) eye.mat[i][j] = i == j ? 1 : 0; return eye; } Matrix33 Matrix33::getTransposed() const { Matrix33 t; for (int i=0;i<3; i++) for (int j=0;j<3;j++) t.mat[i][j] = mat[j][i]; return t; } Vector3 Vector3::zero() { Vector3 v = { 0,0,0 }; return v; } Vector3 Vector3::operator-() const { Vector3 v = { -data[0],-data[1],-data[2] }; return v; } Transformation::Transformation() : m_rotation(Matrix33::identity()) , m_translation(Vector3::zero()) { } Transformation::Transformation(const Matrix33& r, const Vector3& t) : m_rotation(r) , m_translation(t) { } Matrix33& Transformation::r() { return m_rotation; } Vector3& Transformation::t() { return m_translation; } const Matrix33& Transformation::r() const { return m_rotation; } const Vector3& Transformation::t() const { return m_translation; } Matrix44 Transformation::getMat44() const { Matrix44 res = Matrix44::identity(); for (int col=0;col<3;col++) { for (int row=0;row<3;row++) { // Copy rotation component res.mat[row][col] = m_rotation.mat[row][col]; } // Copy translation component res.mat[3][col] = m_translation.data[col]; } return res; } Transformation Transformation::getInverted() const { return Transformation(m_rotation.getTransposed(), -m_translation); } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |