| 35 | } |
| 36 | |
| 37 | Vector3 QuaternionError(const Quaternion Q1, |
| 38 | const Quaternion Q2, |
| 39 | Matrix34 *Jacobian1, |
| 40 | Matrix34 *Jacobian2) |
| 41 | { |
| 42 | if(Jacobian1 != nullptr && Jacobian2 != nullptr) |
| 43 | { |
| 44 | /** we want both jacobians */ |
| 45 | typedef ceres::Jet<double, 8> JetType; |
| 46 | |
| 47 | /** init jets */ |
| 48 | QuaternionT<JetType> Q1Jet = Q1.template cast<JetType>(); |
| 49 | Q1Jet.x().v(0) = 1; |
| 50 | Q1Jet.y().v(1) = 1; |
| 51 | Q1Jet.z().v(2) = 1; |
| 52 | Q1Jet.w().v(3) = 1; |
| 53 | QuaternionT<JetType> Q2Jet = Q2.template cast<JetType>(); |
| 54 | Q1Jet.x().v(4) = 1; |
| 55 | Q1Jet.y().v(5) = 1; |
| 56 | Q1Jet.z().v(6) = 1; |
| 57 | Q1Jet.w().v(7) = 1; |
| 58 | |
| 59 | /** apply transformation */ |
| 60 | const VectorT<JetType,3> ErrorJet = QuaternionError<JetType>(Q1Jet, Q2Jet); |
| 61 | |
| 62 | /** extract jacobians */ |
| 63 | Jacobian1->row(0) = ErrorJet(0).v.head(4); |
| 64 | Jacobian1->row(1) = ErrorJet(1).v.head(4); |
| 65 | Jacobian1->row(2) = ErrorJet(2).v.head(4); |
| 66 | |
| 67 | Jacobian2->row(0) = ErrorJet(0).v.tail(4); |
| 68 | Jacobian2->row(1) = ErrorJet(1).v.tail(4); |
| 69 | Jacobian2->row(2) = ErrorJet(2).v.tail(4); |
| 70 | |
| 71 | /** extract mean */ |
| 72 | Vector3 Error; |
| 73 | Error << ErrorJet(0).a, ErrorJet(1).a, ErrorJet(2).a; |
| 74 | return Error; |
| 75 | } |
| 76 | else if(Jacobian1 != nullptr && Jacobian2 == nullptr) |
| 77 | { |
| 78 | /** we want just jacobian 1 */ |
| 79 | typedef ceres::Jet<double, 4> JetType; |
| 80 | |
| 81 | /** init jets */ |
| 82 | QuaternionT<JetType> Q1Jet = Q1.template cast<JetType>(); |
| 83 | Q1Jet.x().v(0) = 1; |
| 84 | Q1Jet.y().v(1) = 1; |
| 85 | Q1Jet.z().v(2) = 1; |
| 86 | Q1Jet.w().v(3) = 1; |
| 87 | |
| 88 | /** apply transformation */ |
| 89 | const VectorT<JetType,3> ErrorJet = QuaternionError<JetType>(Q1Jet, Q2.template cast<JetType>()); |
| 90 | |
| 91 | /** extract jacobians */ |
| 92 | Jacobian1->row(0) = ErrorJet(0).v; |
| 93 | Jacobian1->row(1) = ErrorJet(1).v; |
| 94 | Jacobian1->row(2) = ErrorJet(2).v; |
no outgoing calls
no test coverage detected