<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Physics on My Blog</title><link>https://EMEEEEMMMM.github.io/tags/physics/</link><description>Recent content in Physics on My Blog</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sat, 04 Apr 2026 11:47:35 +0800</lastBuildDate><atom:link href="https://EMEEEEMMMM.github.io/tags/physics/index.xml" rel="self" type="application/rss+xml"/><item><title>Foundations of Vectors And Matrices</title><link>https://EMEEEEMMMM.github.io/posts/foundationsofvectorsandmatrices/</link><pubDate>Sat, 04 Apr 2026 11:47:35 +0800</pubDate><guid>https://EMEEEEMMMM.github.io/posts/foundationsofvectorsandmatrices/</guid><description>&lt;img src="https://EMEEEEMMMM.github.io/" alt="Featured image of post Foundations of Vectors And Matrices" /&gt;&lt;h1 id="vectors-and-matrices"&gt;Vectors And Matrices
&lt;/h1&gt;&lt;p&gt;Vectors and matrices are the fundamental elements in the engine. They are capable for so many things and act important roles in different areas. I&amp;rsquo;m going to introduce some properties about them from a mathematical way.&lt;/p&gt;
&lt;h2 id="vectors"&gt;Vectors
&lt;/h2&gt;&lt;h3 id="definition-of-a-vector"&gt;Definition of a Vector:
&lt;/h3&gt;&lt;p&gt;A vector possesses &lt;strong&gt;magnitude&lt;/strong&gt; (its size or length) and &lt;strong&gt;direction&lt;/strong&gt;. Unlike a scalar quantity, which is defined only by its magnitude, a vector requires both a value and an orientation in the space to be fully described.&lt;/p&gt;
&lt;p&gt;In an $n$ dimensional space, a vector can be represented as:
&lt;/p&gt;
$$
\vec{v} = \begin{pmatrix} v_{1} \\ v_{2} \\ v_{3} \\ \vdots \\ v_{n} \end{pmatrix}
$$&lt;p&gt;Its magnitude can be expressed as:
&lt;/p&gt;
$$
\lVert \vec{v}\rVert = \sqrt{v_{1}^{2} + v_{2}^{2} + v_{3}^{2} + \dots + v_{n}^{2}} = \sqrt{\sum_{i=1}^n v_{i}^{2}}
$$&lt;p&gt;Its direction can be expressed by its unit vector:
&lt;/p&gt;
$$
\hat{v} = \frac{\vec{v}}{\lVert \vec{v} \rVert} = \begin{pmatrix} \frac{v_{1}}{\lVert \vec{v} \rVert} \\ \frac{v_{2}}{\lVert \vec{v} \rVert} \\ \frac{v_{3}}{\lVert \vec{v} \rVert} \\ \vdots \\ \frac{v_{n}}{\lVert \vec{v} \rVert} \end{pmatrix}
$$&lt;h3 id="vector-properties"&gt;Vector Properties:
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;Commutativity of Addition: $\vec{u} + \vec{v} = \vec{v} + \vec{u}$&lt;/li&gt;
&lt;li&gt;Associativity of Addition: $(\vec{u} + \vec{v}) + \vec{w} = \vec{u} + (\vec{v} + \vec{u})$&lt;/li&gt;
&lt;li&gt;Distributivity: $c(\vec{u} + \vec{v}) = c\vec{u} + c\vec{v}$&lt;/li&gt;
&lt;li&gt;Zero Vector: There exists a unique zero vector $\vec{0} = \left( 0, 0, \dots, 0 \right)$ such that $\vec{v} + \vec{0} = \vec{v}$.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="vector-operations"&gt;Vector Operations:
&lt;/h3&gt;&lt;h4 id="addition--subtraction"&gt;Addition &amp;amp; Subtraction:
&lt;/h4&gt;&lt;p&gt;The sum of two vectors $\vec{v}$ and $\vec{u}$ can be visualized by using the &lt;strong&gt;Triangle Law&lt;/strong&gt; or the &lt;strong&gt;Parallelogram Law&lt;/strong&gt;:
&lt;img alt="alt text" class="gallery-image" data-flex-basis="461px" data-flex-grow="192" height="402" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://EMEEEEMMMM.github.io/posts/foundationsofvectorsandmatrices/VectorSum.jpg" width="773"&gt;
Subtraction can also use these two method by adding the negative vectors.&lt;/p&gt;
&lt;h4 id="the-dot-product"&gt;The Dot Product:
&lt;/h4&gt;&lt;p&gt;The dot product of two vectors $\vec{v}$ and ${\vec{u}}$ results in a scalar which can be used in countless areas. It is crucial for determining the angle between the vectors.
&lt;strong&gt;Geometric Interpretation&lt;/strong&gt;:
&lt;/p&gt;
$$
\vec{v} \cdot \vec{u} = \lVert \vec{v} \rVert \lVert \vec{u} \rVert \cos(\theta)
$$&lt;p&gt;
Here $\theta$ is the angle between $\vec{v}$ and $\vec{u}$.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Algebraic Definition&lt;/strong&gt;:
&lt;/p&gt;
$$
\vec{v} \cdot \vec{u} = v_{1} \cdot u_{1} + v_{2} \cdot u_{2} + \dots + v_{n} \cdot u_{n} = \Sigma_{i = 1}^{n} v_{i} u_{i}
$$&lt;p&gt;&lt;strong&gt;Derivation&lt;/strong&gt;:
Consider the dot product in 3 dimensional space where any two vectors can be expressed as $\vec{v}=(x_{1}, y_{1}, z_{1})$ and $\vec{u}=(x_{2}, y_{2}, z_{2})$. The orthonormal basis in the space have these properties:
&lt;/p&gt;
$$
\begin{aligned}
 \hat i \cdot \hat i = \hat j \cdot \hat j = \hat k \cdot \hat k = 1 \\
 \hat i \cdot \hat j = \hat i \cdot \hat k = \hat j \cdot \hat k = 0
\end{aligned}
$$&lt;p&gt;
The two vectors can then be expressed as:
&lt;/p&gt;
$$
\begin{aligned}
 \vec{v} = \begin{bmatrix}
 x_{1} \hat i \\ 
 y_{1} \hat j \\
 z_{1} \hat k
 \end{bmatrix}
 \vec{u} = \begin{bmatrix}
 x_{2} \hat i \\ 
 y_{2} \hat j \\
 z_{2} \hat k
 \end{bmatrix}
\end{aligned}
$$&lt;p&gt;So, we have:
&lt;/p&gt;
$$
\begin{split}
\vec{v} \cdot \vec{u}
&amp;= (x_{1} \hat i + y_{1} \hat j + z_{1} \hat k) \cdot (x_{2} \hat i + y_{2} \hat j + z_{2} \hat k) \\
&amp;= x_{1} x_{2} \hat i \cdot \hat i + x_{1} y_{2} \hat i \cdot \hat j + x_{1} z_{2} \hat i \cdot \hat k + \\
&amp; \phantom{=} y_{1} x_{2} \hat j \cdot \hat i + y_{1} y_{2} \hat j \cdot \hat j + y_{1} z_{2} \hat j \cdot \hat k + \\
&amp; \phantom{=} z_{1} x_{2} \hat k \cdot \hat i + z_{1} y_{2} \hat k \cdot \hat j + z_{1} z_{2} \hat k \cdot \hat k \\
&amp;= x_{1} x_{2} \hat i \cdot \hat i + y_{1} y_{2} \hat j \cdot \hat j + z_{1} z_{2} \hat k \cdot \hat k \\
&amp;= x_{1} x_{2} + y_{1} y_{2} + z_{1} z_{2}
\end{split}
$$&lt;p&gt;Here is a handwriten note to help you understand.
&lt;img alt="alt text" class="gallery-image" data-flex-basis="598px" data-flex-grow="249" height="597" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://EMEEEEMMMM.github.io/posts/foundationsofvectorsandmatrices/DotProduct.jpg" srcset="https://EMEEEEMMMM.github.io/posts/foundationsofvectorsandmatrices/DotProduct_hu_447af0425b46f82.jpg 800w, https://EMEEEEMMMM.github.io/posts/foundationsofvectorsandmatrices/DotProduct.jpg 1489w" width="1489"&gt;&lt;/p&gt;
&lt;p&gt;From the geometric definition, we can derive the relationship for the angle:
&lt;/p&gt;
$$
\cos(\theta) = \frac{\vec{v} \cdot \vec{u}}{\lVert \vec{v} \rVert \lVert \vec{u} \rVert}
$$&lt;p&gt;If $\vec{v} \cdot \vec{u} &amp;gt; 0$, the angle $\theta$ is actue ($0 \leq \theta &amp;lt; \frac{\pi}{2}$).
If $\vec{v} \cdot \vec{u} = 0$, the angle $\theta = \frac{\pi}{2}$, meaning the vectors are perpendicular to each other.
If $\vec{v} \cdot \vec{u} &amp;lt; 0$, the angle $\theta$ is obtuse ($\frac{\pi}{2} &amp;lt; \theta \leq \pi$).&lt;/p&gt;
&lt;h4 id="the-cross-product"&gt;The Cross Product:
&lt;/h4&gt;&lt;p&gt;The cross product is only defined for vectors in three-dimensional space.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Geometric Interpretation&lt;/strong&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Direction: The resulting vector $\vec{v} = \vec{u} \times \vec{w}$ is perpendicular to the plane spanned by $\vec{u}$ and $\vec{w}$. The direction of $\vec{v}$ is determined by the &lt;strong&gt;right-hand rule&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Magnitude: The magnitude of the resulting vector is given by:

$$
\lVert \vec{u} \times \vec{w} \rVert = \lVert \vec{u} \rVert \lVert \vec{w} \rVert \sin(\theta)
$$&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Special Cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Parallel Vectors ($\theta = 0 \enspace or \enspace \pi$): $\sin(\theta)=0$, so $\vec{u} \times \vec{w} = 0$. (The Zero Vector)&lt;/li&gt;
&lt;li&gt;Orthogonal Vectors($\theta = \frac{\pi}{2}$): $\sin(\frac{\pi}{2}) = 1$, so $\lVert \vec{u} \times \vec{w} \rVert = \lVert \vec{u} \rVert \lVert \vec{w} \rVert$. The resulting vector is the largest possible magnitude for the given lengths.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Algebraic Interpretation&lt;/strong&gt;:
For vectors $a=(a_{x},a_{y},a_{z})$, $b=(b_{x},b_{y},b_{z})$, $\hat i, \hat j, \hat k$ is unit vectors for x, y, z respectively(orthonormal basis). We have:
&lt;/p&gt;
$$
\vec{a} \times \vec{b} = \begin{vmatrix}
 i &amp; j &amp; k \\
 a_{x} &amp; a_{y} &amp; a_{z} \\
 b_{x} &amp; b_{y} &amp; b_{z}
\end{vmatrix} = (a_{y} b_{z} - a_{z} b_{y}) \hat i + (a_{z} b_{x} - a_{x} b_{z}) \hat j + (a_{x} b_{y} - a_{y} b_{x}) \hat k
$$&lt;p&gt;In coordinate form:
&lt;/p&gt;
$$
\vec{a} \times \vec{b} = (a_{x}, a_{y}, a_{z}) \times (b_{x}, b_{y}, b_{z}) = (a_{y} b_{z} - a_{z} b_{y}, a_{z} b_{x} - a_{x} b_{z}, a_{x} b_{y} - a_{y} b_{x})
$$&lt;p&gt;&lt;strong&gt;Derivation&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;For the unit vectors $\hat i, \hat j, \hat k$, they have the following properties:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;$\hat i \times \hat j = \hat k, \hat j \times \hat k = \hat i, \hat k \times \hat i = \hat j$&lt;/li&gt;
&lt;li&gt;$\hat j \times \hat i = - \hat k, \hat k \times \hat j = - \hat i, \hat i \times \hat k = - \hat j$&lt;/li&gt;
&lt;li&gt;$\hat i \times \hat i = \hat j \times \hat j = \hat k \times \hat k = 0$&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For $\vec{u}$ and $\vec{v}$ which are in the coordinate system consisting of $\hat i, \hat j, \hat k$ can be expressed as:
&lt;/p&gt;
$$
\begin{aligned}
 \vec{u} = x_{u} \hat i + y_{u} \hat j + z_{u} \hat k \\
 \vec{v} = x_{v} \hat i + y_{v} \hat j + z_{v} \hat k \\
\end{aligned}
$$&lt;p&gt;Then calculate $\vec{u} \times \vec{v}$:
&lt;/p&gt;
$$
\begin{split}
\vec{u} \times \vec{v}
&amp;= (x_{u} \hat i + y_{u} \hat j + z_{u} \hat k) \times (x_{v} \hat i + y_{v} \hat j + z_{v} \hat k) \\
&amp;= x_{u} x_{v} (\hat i \times \hat i) + x_{u} y_{v} (\hat i \times \hat j) + x_{u} z_{v} (\hat i \times \hat k) + \\
&amp; \phantom{=} y_{u} x_{v} (\hat j \times \hat i) + y_{u} y_{v} (\hat j \times \hat j) + y_{u} z_{v} (\hat j \times \hat k) + \\
&amp; \phantom{=} z_{u} x_{v} (\hat k \times \hat i) + z_{u} y_{v} (\hat k \times \hat j) + z_{u} z_{v} (\hat k \times \hat k) \\
&amp;= (y_{u} z_{v} - z_{u} y_{v}) \hat i + (z_{u} x_{v} - x_{u} z_{v}) \hat j + (x_{u} y_{v} - y_{u} x_{v}) \hat k
\end{split}
$$&lt;h2 id="matrices"&gt;Matrices
&lt;/h2&gt;&lt;p&gt;Matrices is a set of numbers in a rectangular array.&lt;/p&gt;
&lt;p&gt;A table of numbers in $m$ rows and $n$ columns arranged by $m \times n$ numbers is called a $m \times n$ matrix. Denoted as:&lt;/p&gt;
$$
A = \begin{bmatrix}
 a_{11} &amp; a_{12} &amp; \dots &amp; a_{1n} \\
 a_{21} &amp; a_{22} &amp; \dots &amp; a_{2n} \\
 \vdots &amp; \vdots &amp; \ddots &amp; \vdots \\
 a_{m1} &amp; a_{m2} &amp; \dots &amp; a_{mn}
\end{bmatrix}
$$&lt;h3 id="matrix-operations"&gt;Matrix Operations:
&lt;/h3&gt;&lt;h4 id="addition--subtraction-1"&gt;Addition &amp;amp; Subtraction:
&lt;/h4&gt;$$
\begin{bmatrix}
 a_{11} &amp; a_{12} &amp; \dots &amp; a_{1n} \\
 a_{21} &amp; a_{22} &amp; \dots &amp; a_{2n} \\
 \vdots &amp; \vdots &amp; \ddots &amp; \vdots \\
 a_{m1} &amp; a_{m2} &amp; \dots &amp; a_{mn}
\end{bmatrix} + 
\begin{bmatrix}
 b_{11} &amp; b_{12} &amp; \dots &amp; b_{1n} \\
 b_{21} &amp; b_{22} &amp; \dots &amp; b_{2n} \\
 \vdots &amp; \vdots &amp; \ddots &amp; \vdots \\
 b_{m1} &amp; b_{m2} &amp; \dots &amp; b_{mn}
\end{bmatrix} = 
\begin{bmatrix}
 a_{11} + b_{11} &amp; a_{12} + b_{12} &amp; \dots &amp; a_{1n} + b_{1n} \\
 a_{21} + b_{21} &amp; a_{22} + b_{22} &amp; \dots &amp; a_{2n} + b_{2n} \\
 \vdots &amp; \vdots &amp; \ddots &amp; \vdots \\
 a_{m1} + b_{m1} &amp; a_{m2} + b_{m2} &amp; \dots &amp; a_{mn} + b_{mn}
\end{bmatrix}
$$&lt;p&gt;Addition of matrices satisfies the following operator laws:
&lt;/p&gt;
$$
\begin{align}
 A + B &amp;= B + A \\
 (A + B) + C &amp;= A + (B + C)
\end{align}
$$&lt;h4 id="scalar-multiplication"&gt;Scalar Multiplication:
&lt;/h4&gt;$$
k \cdot
\begin{bmatrix}
 a_{11} &amp; a_{12} &amp; \dots &amp; a_{1n} \\
 a_{21} &amp; a_{22} &amp; \dots &amp; a_{2n} \\
 \vdots &amp; \vdots &amp; \ddots &amp; \vdots \\
 a_{m1} &amp; a_{m2} &amp; \dots &amp; a_{mn}
\end{bmatrix} =
\begin{bmatrix}
 k \cdot a_{11} &amp; k \cdot a_{12} &amp; \dots &amp; k \cdot a_{1n} \\
 k \cdot a_{21} &amp; k \cdot a_{22} &amp; \dots &amp; k \cdot a_{2n} \\
 \vdots &amp; \vdots &amp; \ddots &amp; \vdots \\
 k \cdot a_{m1} &amp; k \cdot a_{m2} &amp; \dots &amp; k \cdot a_{mn}
\end{bmatrix}
$$&lt;p&gt;The scalar multiplication of a matrix satisfies the following operator laws:
&lt;/p&gt;
$$
\begin{aligned}
 \lambda(\mu A) &amp;= \mu(\lambda A) \\ 
 \lambda(\mu A) &amp;= (\lambda \mu) A \\ 
 (\lambda + \mu) A &amp;= \lambda A + \mu A \\
 \lambda(A + B) &amp;= \lambda A + \lambda B 
\end{aligned}
$$&lt;h4 id="transpose"&gt;Transpose:
&lt;/h4&gt;&lt;p&gt;The matrix resulting from interchanging the rows and the columns of the matrix A is called the transposed matrix of A ($A^T$)
&lt;/p&gt;
$$
\begin{bmatrix}
 a_{11} &amp; a_{12} &amp; a_{13} \\
 a_{21} &amp; a_{22} &amp; a_{23} \\
\end{bmatrix} ^ T = \begin{bmatrix}
 a_{11} &amp; a_{21} \\
 a_{12} &amp; a_{22} \\
 a_{13} &amp; a_{23}
\end{bmatrix}
$$&lt;p&gt;The transpose of a matrix satisifes the following operator laws:
&lt;/p&gt;
$$
\begin{align}
 (A^T)^T &amp;= A \\
 (\lambda A)^T &amp;= \lambda A^T \\
 (AB)^T &amp;= B^T A^T 
\end{align}
$$&lt;h4 id="multiplication"&gt;Multiplication:
&lt;/h4&gt;&lt;p&gt;If $A$ is a $m \times n$ matrix and $B$ is a $n \times p$ matrix, their product $C$ is a $m \times p$ matrix $C = (c_{ij})$, any of its element can be expressed as:
&lt;/p&gt;
$$
c_{i,j} = a_{i,1}b_{1,j} + a_{i,2}b_{2,j} + \cdots + a_{i,n}b_{n,j} = \Sigma_{r=1}^n a_{i,r}b{r,j}
$$&lt;p&gt;
This product can be denoted as: $C = AB$&lt;/p&gt;
&lt;p&gt;The multiplication of matrices satisfies following operators:
&lt;/p&gt;
$$
\begin{align}
 (AB)C = A(BC) \\
 (A+B)C = AC + BC \\
 C(A+B) = CA + CB
\end{align}
$$</description></item><item><title>Impulse Solution</title><link>https://EMEEEEMMMM.github.io/posts/impulsesolution/</link><pubDate>Tue, 31 Mar 2026 19:30:31 +0800</pubDate><guid>https://EMEEEEMMMM.github.io/posts/impulsesolution/</guid><description>&lt;img src="https://EMEEEEMMMM.github.io/" alt="Featured image of post Impulse Solution" /&gt;&lt;h1 id="problem"&gt;Problem:
&lt;/h1&gt;&lt;p&gt;For a rigid body A with mass $m_{A}$ and another rigid body B with mass $m_{B}$ collide with linear velocity $v_{A},v_{B}$ respectively, solve for the scalar impulse $j$ of the two object. Friction is negligible.&lt;/p&gt;
&lt;h1 id="variables"&gt;Variables:
&lt;/h1&gt;&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th style="text-align: left"&gt;Symbol&lt;/th&gt;
 &lt;th&gt;Definition&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$m_{A},m_{B}$&lt;/td&gt;
 &lt;td&gt;Mass of object A and B&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$I_{A},I_{B}$&lt;/td&gt;
 &lt;td&gt;Moment of inertia tensor of object A and B&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$x_{A},x_{B}$&lt;/td&gt;
 &lt;td&gt;Center of Mass&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$P$&lt;/td&gt;
 &lt;td&gt;Contact point&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$r_{A},r_{B}$&lt;/td&gt;
 &lt;td&gt;$P-x$&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$v_{A},v_{B}$&lt;/td&gt;
 &lt;td&gt;linear velocity before impact&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$\omega_{A},\omega_{B}$&lt;/td&gt;
 &lt;td&gt;Angular velocity before impact&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$v_{PA},v_{PB}$&lt;/td&gt;
 &lt;td&gt;Absolute linear velocity of the contact point&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$v_{rel}$&lt;/td&gt;
 &lt;td&gt;relative velocity of contact point&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$n$&lt;/td&gt;
 &lt;td&gt;Contact normal (unit vector)&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$e$&lt;/td&gt;
 &lt;td&gt;coefficient of restitution&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$J$&lt;/td&gt;
 &lt;td&gt;impulse vector&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td style="text-align: left"&gt;$j$&lt;/td&gt;
 &lt;td&gt;impulse scalar&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;h1 id="derivation"&gt;Derivation:
&lt;/h1&gt;&lt;p&gt;The velocity of any point on a rigid body is the sum of its linear velocity and its tangential velocity due to rotation.
From the definition:&lt;/p&gt;
$$
\begin{align}
r_{A} = P - x_{A}, r_{B} = P - x_{B} 
\begin{aligned}
v_{PA} &amp;=v_{A}+\omega_{A} \times r_{A} \\
v_{PB} &amp;= v_{B}+\omega_{B} \times r_{B} \\
\end{aligned}
\end{align}
$$&lt;p&gt;The relative velocity of body B with respect to body A at the contact point:&lt;/p&gt;
$$
v_{rel} = v_{PB} - v_{PA}
$$&lt;p&gt;
The impulse $J$ acts along the contact normal $n$:
&lt;/p&gt;
$$
J = jn
$$&lt;p&gt;
According to Impulse-Momentum Theorem ($\Delta v=\frac{J}{m}$):
&lt;/p&gt;
$$
\begin{align}
v_{A}'=v_{A}-\frac{j}{m_{A}}n \\
v_{B}'=v_{B}+\frac{j}{m_{B}}n
\end{align}
$$&lt;p&gt;
The impulse also applies a torque which changes the angular velocities ($\Delta \omega = I^{-1}(r \times J)$):
&lt;/p&gt;
$$
\begin{align}
\omega_{A}'=\omega_{A} - I^{-1}_{A}(r_{A}\times jn) \\
\omega_{B}'=\omega_{B} + I^{-1}_{B}(r_{B}\times jn)
\end{align}
$$&lt;p&gt;
Then the velocity of the contact point immediately after the impact can be expressed as:
&lt;/p&gt;
$$
\begin{align}
v_{PA}'=v_{A}'+\omega_{A}'\times r_{A} \\ \\
v_{PB}'=v_{B}'+\omega_{B}'\times r_{B}
\end{align}
$$&lt;p&gt;
Substitute the equations into this expression:
&lt;/p&gt;
$$
\begin{align}
v_{PA}' &amp;= (v_{A}-\frac{j}{m_{A}}n)+(\omega_{A} - I^{-1}_{A}(r_{A}\times jn)) \times r_{A} \\
v_{PB}' &amp;= (v_{B}+\frac{j}{m_{B}}n) + (\omega_{B} + I^{-1}_{B}(r_{B}\times jn)) \times r_{B}
\end{align}
$$&lt;p&gt;
Factor out the $j$ and simplify:
&lt;/p&gt;
$$
\begin{align}
v_{PA}' &amp;= v_{PA} - j[\frac{n}{m_{A}} + (I^{-1}_{A}(r_{A}\times n)) \times r_{A}] \\
v_{PB}' &amp;= v_{PB} + j[\frac{n}{m_{B}} + (I^{-1}_{B}(r_{B}\times n)) \times r_{B}]
\end{align}
$$&lt;p&gt;
The new relative velocity:
&lt;/p&gt;
$$
\begin{align}
v_{rel}'=v_{PB}'-v_{PA}'&amp;= ((v_{B}+\frac{j}{m_{B}}n) + (\omega_{B} + I^{-1}_{B}(r_{B}\times jn)) \times r_{B}) - (v_{PA} - j[\frac{n}{m_{A}} + (I^{-1}_{A}(r_{A}\times n)) \times r_{A}]) \\
v_{rel}'&amp;=v_{rel}+j(\frac{n}{m_{A}} + (I^{-1}_{A}(r_{A}\times n)) \times r_{A} + \frac{n}{m_{B}} + (I^{-1}_{B}(r_{B}\times n)) \times r_{B})
\end{align}
$$&lt;p&gt;
According to Newton&amp;rsquo;s law of Restitution, the ratio of the relative speed of separation and the relative speed of approach when two objects collide equals to the coefficient of restitution.
&lt;/p&gt;
$$
v_{rel}' \cdot n = -e (v_{rel} \cdot n), e \in [0, 1]
$$&lt;p&gt;
Substitute $v_{rel}&amp;rsquo;$ and simplify the equation:
&lt;/p&gt;
$$
\begin{align}
\left[ v_{rel}+j\left( \frac{n}{m_{A}} + (I^{-1}_{A}(r_{A}\times n)) \times r_{A} + \frac{n}{m_{B}} + (I^{-1}_{B}(r_{B}\times n)) \times r_{B} \right) \right] \cdot n &amp;= -e (v_{rel} \cdot n) \\
j\left( \frac{n}{m_{A}} + (I^{-1}_{A}(r_{A}\times n)) \times r_{A} + \frac{n}{m_{B}} + (I^{-1}_{B}(r_{B}\times n)) \times r_{B} \right) \cdot n &amp;= -(1+e)(v_{rel} \cdot n) \\
j = \frac{-(1+e)(v_{rel} \cdot n)}{\left( \frac{n}{m_{A}} + (I^{-1}_{A}(r_{A}\times n)) \times r_{A} + \frac{n}{m_{B}} + (I^{-1}_{B}(r_{B}\times n)) \times r_{B} \right) \cdot n } \\
j = \frac{-(1+e)(v_{rel} \cdot n)}{ \frac{1}{m_{A}} + \frac{1}{m_{B}} + \left[(I^{-1}_{A}(r_{A}\times n)) \times r_{A} + (I^{-1}_{B}(r_{B}\times n)) \times r_{B} \right] \cdot n }
\end{align}
$$</description></item><item><title>The Integrator</title><link>https://EMEEEEMMMM.github.io/posts/theintegrator/</link><pubDate>Fri, 13 Mar 2026 23:07:28 +0800</pubDate><guid>https://EMEEEEMMMM.github.io/posts/theintegrator/</guid><description>&lt;img src="https://EMEEEEMMMM.github.io/" alt="Featured image of post The Integrator" /&gt;&lt;h2 id="the-physical-model"&gt;The Physical Model
&lt;/h2&gt;&lt;p&gt;All integration algorithms are derived from Newton&amp;rsquo;s second law of motion. For a particle subjected to a force $F$:&lt;/p&gt;
$$
\begin{align}
F = ma = m \frac{d^2x}{dt^2}
\end{align}
$$&lt;p&gt;We usually split it into two first-order differential equation:&lt;/p&gt;
$$
\left\{
\begin{aligned}
\frac{dx}{dt} &amp; = v \\
\frac{dv}{dt} &amp; = a = \frac{F_{net}}{m}
\end{aligned}
\right.
$$&lt;h3 id="explicit-euler"&gt;Explicit Euler
&lt;/h3&gt;&lt;p&gt;This is the most intuitive solution, assume the step is $\Delta t$:
&lt;/p&gt;
$$
x_{n+1} = x_{n} + v_{n} \Delta t \\
v_{n+1} = v_{n} + a_{n} \Delta t
$$&lt;p&gt;But it is extremely unreliable since it actually assumes that in a step, the velocity and the acceleration are constant.&lt;/p&gt;
&lt;h3 id="semi-implicit-euler"&gt;Semi-Implicit Euler
&lt;/h3&gt;&lt;p&gt;This is what I used in my project and it has just a slightly change compare to Explicit Euler, it updates the velocity and uses the new velocity to update the position.&lt;/p&gt;
$$
v_{n+1} = v_{n} + a_{n} \Delta t \\
x_{n+1} = x_{n} + v_{n+1} \Delta t
$$&lt;p&gt;It is much more reliable than the Explicit Euler.&lt;/p&gt;
&lt;p&gt;Note: Rk4 and Implicit Euler is not considered here since they much more complicated than the above two methods and in most cases, semi-implicit euler can do its job pretty well.&lt;/p&gt;
&lt;h2 id="the-moment-of-inertia-matrix"&gt;The Moment of Inertia Matrix
&lt;/h2&gt;&lt;p&gt;In 3D space, the &amp;ldquo;resistance to rotation&amp;rdquo; of an object is different for different axis. This cannot be expressed by a constant, but rather as a matrix of 3x3, which completely describes the distribution of mass in all directions. As long as the shape of the object does not collapse, this $I_{body}$ will not change.&lt;/p&gt;
&lt;p&gt;For the world coordinate system, the &amp;ldquo;resistance to rotation&amp;rdquo; of the object is keep changing with its posture. Which means that, we must convert the $I_{body}$ to the $I_{world}$ all the time so that we can calculate the effect of the external forces on it correctly.&lt;/p&gt;
&lt;p&gt;We know the Angular Momentum Theorem:&lt;/p&gt;
$$
L = I \omega
$$&lt;p&gt;It is true for both the world space and the local space:
&lt;/p&gt;
$$
\begin{align}
L_{local} &amp;= I_{body} \omega_{local} \\
L_{world} &amp;= I_{world} \omega_{world} 
\end{align}
$$&lt;p&gt;To convert a vector from the local space to the world space, multiply current rotation matrix $R$:&lt;/p&gt;
$$
\begin{align}
L_{world} &amp;= R L_{local} \\
\omega_{world} &amp;= R \omega_{local} \\
\omega_{local} &amp;= R^{-1} \omega_{world}
\end{align}
$$&lt;blockquote class="alert alert-note"&gt;
 &lt;div class="alert-header"&gt;
 &lt;span class="alert-icon"&gt;📝&lt;/span&gt;
 &lt;span class="alert-title"&gt;Note:&lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="alert-body"&gt;
 &lt;p&gt;&lt;/p&gt;
$$
\left[
\begin{matrix}
R_{11} &amp; R_{12} &amp; R_{13} \\
R_{21} &amp; R_{22} &amp; R_{23} \\
R_{31} &amp; R_{32} &amp; R_{33}
\end{matrix}
\right]
\left[
\begin{matrix}
x_{local} \\
y_{local} \\
z_{local}
\end{matrix}
\right] = \left[
\begin{matrix}
x_{world} \\
y_{world} \\
z_{world}
\end{matrix}
\right]
$$
 &lt;/div&gt;
 &lt;/blockquote&gt;
&lt;p&gt;Substitutes:&lt;/p&gt;
$$
\begin{align}
L_{world} &amp;= R (I_{body} \omega_{local}) \\
L_{world} &amp;= R I_{body} R^{-1} \omega_{world}
\end{align}
$$&lt;p&gt;So $I_{world}$ is equal to:&lt;/p&gt;
$$
I_{world} = R I_{body} R^{-1}
$$&lt;p&gt;And in the physics engine, we care about its inverse matrix because we need it to calculate the angular acceleration.&lt;/p&gt;
$$
\begin{align}
I_{world}^{-1} &amp;= (R I_{body} R^{-1})^{-1} \\ 
I_{world}^{-1} &amp;= (R^{-1})^{-1} I_{body}^{-1} R^{-1} \\
R^{-1} &amp;= R^T \\
I_{world}^{-1} &amp;= R I_{body}^{-1} R^T \\
\end{align}
$$&lt;blockquote class="alert alert-note"&gt;
 &lt;div class="alert-header"&gt;
 &lt;span class="alert-icon"&gt;📝&lt;/span&gt;
 &lt;span class="alert-title"&gt;Note: Replace the $R^{-1}$ by $R^T$ is because calculate $R^T$ is much faster than $R^{-1}$.&lt;/span&gt;
 &lt;/div&gt;
 &lt;div class="alert-body"&gt;
 
 &lt;/div&gt;
 &lt;/blockquote&gt;
&lt;h2 id="the-angular-acceleration"&gt;The Angular Acceleration
&lt;/h2&gt;$$
\begin{align}
\tau &amp;= \frac{dL}{dt} \\
L &amp;= I \omega 
\end{align}
$$&lt;p&gt;Assume $I$ stays constant in a short period of time:
&lt;/p&gt;
$$
\tau = \frac{d(I\omega)}{dt} = I\frac{d\omega}{dt} \\
\tau = I \alpha
$$&lt;p&gt;In 3D space, $\tau$ and $\alpha$ are vectors with size 3x1. $I$ is a matrix of size 3x3.&lt;/p&gt;
$$
\left[
\begin{matrix}
\tau_{x} \\
\tau_{y} \\
\tau_{z}
\end{matrix}
\right]
= \left[
\begin{matrix}
I_{xx} &amp; I_{xy} &amp; I_{xz} \\
I_{yx} &amp; I_{yy} &amp; I_{yz} \\
I_{zx} &amp; I_{zy} &amp; I_{zz} \\
\end{matrix}
\right]
\left[
\begin{matrix}
\alpha_{x} \\
\alpha_{y} \\ 
\alpha_{z}
\end{matrix}
\right] \\
\begin{align}
I^{-1} \tau &amp;= (I^{-1}I)\alpha \\
I^{-1} \tau &amp;= \alpha \\
\alpha &amp;= I_{world}^{-1} \tau \\
\omega_{n+1} &amp;= \omega_{n} + \alpha \Delta t
\end{align}
$$&lt;h2 id="summary"&gt;Summary
&lt;/h2&gt;&lt;p&gt;So, for each object in every time step, these should be updated by the integrator:
&lt;/p&gt;
$$
\begin{align}
v_{n+1} &amp;= v_{n} + a_{n} \Delta t \\
x_{n+1} &amp;= x_{n} + v_{n+1} \Delta t \\
I_{world}^{-1} &amp;= R I_{body}^{-1} R^T \\
\alpha &amp;= I_{world}^{-1} \tau \\
\omega_{n+1} &amp;= \omega_{n} + \alpha \Delta t
\end{align}
$$</description></item></channel></rss>