- Game Physics Cookbook
- Gabor Szauer
- 267字
- 2021-04-02 20:27:28
Determinant of a 2x2 matrix
Determinants are useful for solving systems of linear equations; however, in the context of a 3D physics engine, we use them almost exclusively to find the inverse of a matrix. The determinant of a matrix M is a scalar value, it's denoted as .The determinant of a matrix is the same as the determinant of its transpose
.
We can use a shortcut to find the determinant of a 2 X 2 matrix; subtract the product of the diagonals. This is actually the manually expanded form of Laplace Expansion; we will cover the proper formula in detail later:

One interesting property of determinants is that the determinant of the inverse of a matrix is the same as the inverse determinant of that matrix:

Finding the determinant of a 2 X 2 matrix is fairly straightforward, as we have already expanded the formula. We're just going to implement this in code.
How to do it…
Follow these steps to implement a function which returns the determinant of a 2 X 2 matrix:
- Add the declaration for the determinant function to
matrices.h
:float Determinant(const mat2& matrix);
- Add the implementation for the determinant function to
matrices.cpp
:float Determinant(const mat2& matrix) { return matrix._11 * matrix._22 – matrix._12 * matrix._21; }
- MongoDB for Java Developers
- ASP.NET Core Essentials
- HTML5+CSS3基礎開發教程(第2版)
- INSTANT Mercurial SCM Essentials How-to
- Building a Quadcopter with Arduino
- Web程序設計(第二版)
- 精通網絡視頻核心開發技術
- bbPress Complete
- Hands-On Automation Testing with Java for Beginners
- 飛槳PaddlePaddle深度學習實戰
- 快人一步:系統性能提高之道
- Spring核心技術和案例實戰
- Building Android UIs with Custom Views
- Solr Cookbook(Third Edition)
- FFmpeg開發實戰:從零基礎到短視頻上線