Skip to content
Snippets Groups Projects
Commit 8b28d182 authored by Oliver Sander's avatar Oliver Sander Committed by sander@FU-BERLIN.DE
Browse files

Reimplement method secondDerivativeOfDistanceSquaredWRTFirstAndSecondArgument

The new implementation properly handles the double-sheet structure

[[Imported from SVN: r8372]]
parent f28a17f7
No related branches found
No related tags found
No related merge requests found
...@@ -658,19 +658,40 @@ public: ...@@ -658,19 +658,40 @@ public:
return A; return A;
} }
/** \brief Compute the mixed second derivate \partial d^2 / \partial da db /** \brief Compute the mixed second derivate \partial d^2 / \partial dp dq */
Unlike the distance itself the squared distance is differentiable at zero
*/
static Dune::FieldMatrix<T,4,4> secondDerivativeOfDistanceSquaredWRTFirstAndSecondArgument(const Rotation<T,3>& p, const Rotation<T,3>& q) { static Dune::FieldMatrix<T,4,4> secondDerivativeOfDistanceSquaredWRTFirstAndSecondArgument(const Rotation<T,3>& p, const Rotation<T,3>& q) {
// use the functionality from the unitvector class
Dune::FieldMatrix<T,4,4> result = UnitVector<T,4>::secondDerivativeOfDistanceSquaredWRTFirstAndSecondArgument(p.globalCoordinates(), T sp = p.globalCoordinates() * q.globalCoordinates();
q.globalCoordinates());
// The unit quaternions form a double cover of SO(3). That means going once around the unit sphere (2\pi) // Compute vector A (see notes)
// means going twice around SO(3) (4\pi). Hence there is a factor 2, which in addition we need to square, Dune::FieldMatrix<T,1,4> row;
// because we are considering the squared distance. row[0] = q.projectOntoTangentSpace(p.globalCoordinates());
result *= 4;
return result; EmbeddedTangentVector tmp = p.projectOntoTangentSpace(q.globalCoordinates());
Dune::FieldMatrix<T,4,1> column;
for (int i=0; i<4; i++) // turn row vector into column vector
column[i] = tmp[i];
Dune::FieldMatrix<T,4,4> A;
// A = row * column
Dune::FMatrixHelp::multMatrix(column,row,A);
A *= 4 * UnitVector<T,4>::secondDerivativeOfArcCosSquared(std::fabs(sp));
// Compute matrix B (see notes)
Dune::FieldMatrix<T,4,4> Pp, Pq;
for (int i=0; i<4; i++)
for (int j=0; j<4; j++) {
Pp[i][j] = (i==j) - p.globalCoordinates()[i]*p.globalCoordinates()[j];
Pq[i][j] = (i==j) - q.globalCoordinates()[i]*q.globalCoordinates()[j];
}
Dune::FieldMatrix<T,4,4> B;
Dune::FMatrixHelp::multMatrix(Pp,Pq,B);
// Bring it all together
A.axpy(4 * ( (sp<0) ? -1 : 1) * UnitVector<T,4>::derivativeOfArcCosSquared(std::fabs(sp)), B);
return A;
} }
/** \brief Compute the third derivative \partial d^3 / \partial dq^3 /** \brief Compute the third derivative \partial d^3 / \partial dq^3
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment