Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sjhalayka/00f4748e9893413225c335cef0c84320 to your computer and use it in GitHub Desktop.
Save sjhalayka/00f4748e9893413225c335cef0c84320 to your computer and use it in GitHub Desktop.
double determinant(const Matrix3d& m)
{
// https://textbooks.math.gatech.edu/ila/determinants-volumes.html
// https://copilot.microsoft.com/chats/qQxM5K1jer1Dc6pMtuDfD
Vector3d a;
a(0) = m(0, 0);
a(1) = m(0, 1);
a(2) = m(0, 2);
Vector3d b;
b(0) = m(1, 0);
b(1) = m(1, 1);
b(2) = m(1, 2);
Vector3d c;
c(0) = m(2, 0);
c(1) = m(2, 1);
c(2) = m(2, 2);
Vector3d cross = b.cross(c);
return std::abs(a.dot(cross));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment