-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblog_matrices_2x2determinant.html
51 lines (39 loc) · 4.67 KB
/
blog_matrices_2x2determinant.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Gabor Makes Games</title>
<meta name="author" content="Gabor Szauer">
<link rel="stylesheet" type="text/css" href="css/shared.css"><link rel="stylesheet" type="text/css" href="css/navigation.css"><link rel="stylesheet" type="text/css" href="css/font-raleway.css"><link rel="stylesheet" type="text/css" href="css/font-oxygen.css"><link rel="stylesheet" type="text/css" href="css/font-worksans.css"><link rel="stylesheet" type="text/css" href="css/codepretty/skins/desert.css"><script type="text/javascript" src="js/codepretty/prettify.js"></script><link rel="stylesheet" type="text/css" href="css/katex.min.css"><script type="text/javascript" src="js/katex.min.js"></script><script type="text/javascript" src="js/katex-autorender.min.js"></script><script type="text/javascript" src="js/navigation.js"></script><!-- Global site tag (gtag.js) - Google Analytics --><script async src="https://www.googletagmanager.com/gtag/js?id=UA-96941899-3"></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'UA-96941899-3');</script> <link rel="stylesheet" type="text/css" href="css/blog.css">
</head>
<body onload="MainNavOnLoad();renderMathInElement(document.body);PR.prettyPrint();"> <div class="nav"> <ul class="menu"> <li class="logo"><a href="https://gabormakesgames.com">Gabor Makes Games</a></li> <li class="item"><a id="main-nav-active" href="blog.html">Blog</a></li> <li class="item"><a href="books.html">Books</a></li> <li class="item"><a href="https://github.com/gszauer/">Github</a></li> <li class="item"><a href="https://twitter.com/gszauer">@gszauer</a></li> <li class="toggle"><a href="#">Open Menu</a></li> </ul></div>
<div id="blog">
<div id="sidebar"><a class="sidebar-item sidebar-first sidebar-gap" href="blog.html">Back to blog</a></li><a class="sidebar-item sidebar-first" href="matrices.html">Introduction</a><a class="sidebar-item" href="blog_matrices_topology.html">Topology</a><a class="sidebar-item" href="blog_matrices_transpose.html">Transpose</a><a class="sidebar-item" href="blog_matrices_component.html">Component Operations</a><a class="sidebar-item" href="blog_matrices_multiplication.html">Multiplication</a><a class="sidebar-item" href="blog_matrices_vectors.html">Vectors</a><a class="sidebar-item" href="blog_matrices_invert.html">Invert</a><a class="sidebar-item sidebar-tab sidebar-active " href="blog_matrices_2x2determinant.html">2x2 Determinant</a><a class="sidebar-item sidebar-tab" href="blog_matrices_minors.html">Minors</a><a class="sidebar-item sidebar-tab" href="blog_matrices_cofactor.html">Cofactor</a><a class="sidebar-item sidebar-tab" href="blog_matrices_laplace.html">Laplace Expansion</a><a class="sidebar-item sidebar-tab" href="blog_matrices_adjugate.html">Adjugate</a></div>
<div id="content">
<h1>2x2 Determinant</h1>
<p>The determinant of matrix \(M\) is commonly denoted as \(det(M)\), \(det M\) or \(|M|\). In practice, the absolute value of the determinant gives the scale factor by which the matrix will scale a volume. This definition is not really used in games, for games the determinant is a helper function to find the inverse of a matrix.</p>
<p>The determinant of a matrix is the same as the determinant of its transpose, \(|M| = |M^{T}|\). Similarly, the determinant of the inverse of a matrix is the same as the inverse of it's determinant: \(|M^{-1}| = \frac{1}{|M|}\)</p>
<p>Finding the determinant of a matrix is actually a recursive operation. Before learning about the recursive nature of the operation, let's explore the determinant of our smallest square matrix, a 2x2 matrix. Consider this 2x2 matrix:</p>
<p>$$
M =
\begin{bmatrix}
a & c\\
b & d
\end{bmatrix}
$$</p>
<p>To find the determinant of the above matrix, you need to multiply diagonal elements and subtract the result. For example, the determinant of the above matrix would be <code>a * d - c * b</code>. A simple way to express this is:
<p>$$
|M| = |
\begin{bmatrix}
a & c\\
b & d
\end{bmatrix}
| = ad - cb
$$</p>
<pre class="prettyprint linenums">float Determinant(mat2 m) {
return m.v[0] * m.v[3] - m.v[2] * m.v[1];
}</pre>
</div>
</div>
</body>
</html>