- 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; }
- Getting Started with Gulp(Second Edition)
- Python科學計算(第2版)
- Visual C++實例精通
- 深入淺出DPDK
- 精通Scrapy網絡爬蟲
- CKA/CKAD應試教程:從Docker到Kubernetes完全攻略
- Redis Essentials
- 好好學Java:從零基礎到項目實戰
- Java語言程序設計教程
- 零基礎學Scratch 3.0編程
- Ext JS 4 Plugin and Extension Development
- 從零開始學Selenium自動化測試:基于Python:視頻教學版
- AI自動化測試:技術原理、平臺搭建與工程實踐
- Visual C++程序設計與項目實踐
- AI輔助編程Python實戰:基于GitHub Copilot和ChatGPT