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

compute the mixed second derivative of the squared distance function

[[Imported from SVN: r6293]]
parent 418e69f1
Branches
No related tags found
No related merge requests found
...@@ -149,6 +149,43 @@ public: ...@@ -149,6 +149,43 @@ public:
return result; return result;
} }
/** \brief Compute the mixed second derivate \partial d^2 / \partial da db
Unlike the distance itself the squared distance is differentiable at zero
*/
static Dune::FieldMatrix<double,dim,dim> secondDerivativeOfDistanceSquaredWRTFirstAndSecondArgument(const UnitVector& a, const UnitVector& b) {
Dune::FieldMatrix<double,dim,dim> result;
double sp = a.data_ * b.data_;
// Compute vector A (see notes)
Dune::FieldMatrix<double,1,dim> row;
row[0] = b.globalCoordinates();
row *= secondDerivativeOfArcCosSquared(sp);
Dune::FieldMatrix<double,dim,1> column = b.projectOntoTangentSpace(a.globalCoordinates());
Dune::FieldMatrix<double,dim,dim> A;
// A = row * column
Dune::FMatrixHelp::multMatrix(column,row,A);
// Compute matrix B (see notes)
Dune::FieldMatrix<double,dim,dim> B;
for (int i=0; i<dim; i++)
for (int j=0; j<dim; j++)
B[i][j] = (i==j) - b.data_[i]*b.data_[j];
// Bring it all together
result = A;
result.axpy(derivativeOfArcCosSquared(sp), B);
for (int i=0; i<dim; i++)
result[i] = a.projectOntoTangentSpace(result[i]);
return result;
}
/** \brief Project tangent vector of R^n onto the tangent space */ /** \brief Project tangent vector of R^n onto the tangent space */
EmbeddedTangentVector projectOntoTangentSpace(const EmbeddedTangentVector& v) const { EmbeddedTangentVector projectOntoTangentSpace(const EmbeddedTangentVector& v) const {
EmbeddedTangentVector result = v; EmbeddedTangentVector result = v;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment