jacobienne

This commit is contained in:
FyloZ 2024-03-12 21:24:24 -04:00
parent f41b71588f
commit caf83ef7ca
Signed by: william
GPG Key ID: 835378AE9AF4AE97
2 changed files with 26 additions and 4 deletions

View File

@ -318,6 +318,28 @@ namespace gti320 {
return *this;
}
/**
* Opérateur de d'addition d'une autre matrice
*
* Ajoute toutes les entrées de la matrice dans la sous-matrice.
*
* Note : la taille de la matrice doit correspondre à la taille de la
* sous-matrice.
*/
template<typename _OtherScalar, int _OtherRows, int _OtherCols, int _OtherStorage>
SubMatrix &operator+=(const Matrix<_OtherScalar, _OtherRows, _OtherCols, _OtherStorage> &matrix) {
assert(this->rows() == matrix.rows());
assert(this->cols() == matrix.cols());
for (int col = 0; col < this->cols(); col++) {
for (int row = 0; row < this->rows(); row++) {
(*this)(row, col) = (*this)(row, col) + matrix(row, col);
}
}
return *this;
}
/**
* Accesseur aux entrées de la sous-matrice (lecture seule)
*

View File

@ -145,9 +145,9 @@ void ParticleSystem::buildDfDx(Matrix<float, Dynamic, Dynamic> &dfdx) {
Matrix<float, 2, 2> ndiag = -1.0f * diag;
dfdx.block(spring.index0, spring.index1, 2, 2) = diag;
dfdx.block(spring.index0 + 2, spring.index1 + 2, 2, 2) = diag;
dfdx.block(spring.index0 + 2, spring.index1, 2, 2) = ndiag;
dfdx.block(spring.index0, spring.index1 + 2, 2, 2) = ndiag;
dfdx.block(spring.index0, spring.index1, 2, 2) += diag;
dfdx.block(spring.index0 + 2, spring.index1 + 2, 2, 2) += diag;
dfdx.block(spring.index0 + 2, spring.index1, 2, 2) += ndiag;
dfdx.block(spring.index0, spring.index1 + 2, 2, 2) += ndiag;
}
}