Added the section structure to theoretical background.

Written the computation of the moment of inertia of the rectangle and
regular polygons.
This commit is contained in:
Karma Riuk 2023-05-28 10:14:47 +02:00
parent 757db58bab
commit 3372554313
16 changed files with 378 additions and 1 deletions

Binary file not shown.

View File

@ -70,16 +70,24 @@
\begin{document}
\maketitle
\tableofcontents
\newpage
\subfile{./sections/intro.tex}
\newpage
\subfile{./sections/tech_background.tex}
\newpage
\subfile{./sections/theoretical_background.tex}
\newpage
\subfile{./sections/solution.tex}
\newpage
\subfile{./sections/conclusion.tex}
\newpage
%%%%%
\bibliographystyle{abbrv}
\bibliographystyle{unsrt}
\bibliography{references}
\newpage
\subfile{./sections/appendix.tex}
\end{document}

BIN
figures/isosceles.pdf Normal file

Binary file not shown.

BIN
figures/pentagon.pdf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

46
sections/appendix.tex Normal file
View File

@ -0,0 +1,46 @@
\appendix
\section{Calculations}
\label{appendix:calculations}
\paragraph{Moment of inertia of rectangle}
\begin{equation}
\label{eq:rect_moment_long}
\begin{split}
I_{\text{rect}} & =
\rho \int_{-\frac{h}{2}}^{\frac{h}{2}} \int_{-\frac{w}{2}}^{\frac{w}{2}} x^2 + y^2 \diff x \diff y \\
& = 4 \rho \int_{0}^{\frac{h}{2}} \int_{0}^{\frac{w}{2}} x^2 + y^2 \diff x \diff y \\
& = 4 \rho \int_{0}^{\frac{h}{2}} \Biggl[\frac{1}{3} x^3 + x y^2 \Biggr]_{0}^{\frac{w}{2}} dy \\
& = 4 \rho \int_{0}^{\frac{h}{2}} \frac{1}{3} \frac{w^3}{8} + \frac{w}{2} y^2 dy \\
& = 2 \rho \int_{0}^{\frac{h}{2}} \frac{w^3}{12} + w y^2 dy \\
& = 2 \rho \Biggl[ \frac{w^3}{12} y + \frac{w}{3} y^3 \Biggr]_{0}^{\frac{h}{2}} \\
& = 2 \rho \frac{w}{3} \Biggl[ \frac{w^2}{4}y + y^3 \Biggr]_{0}^{\frac{h}{2}} \\
& = 2 \rho \frac{w}{3} \left( \frac{w^2}{4}\frac{h}{2} + \frac{h^3}{8} \right) \\
& = \rho \frac{w}{3} \left( \frac{w^2}{4}h + \frac{h^3}{4} \right) \\
& = \frac{\rho wh}{12} \left( w^2 + h^3 \right) \\
\end{split}
\end{equation}
\newpage
\paragraph{Moment of inertia of sub-triangle of regular polygon}
Before starting the calculations, it is to be noted that according to Figure
\ref{fig:subtriangle}, we have that
$$ \tan\left(\frac{\theta}{2}\right) = \frac{\frac{l}{2}}{h} = \frac{l}{2h} $$
it will be useful to simplify the result of the integral.
\begin{equation}
\label{eq:subtriangle_moment_long}
\begin{split}
I_{T} &= \rho \int_0^h\int_{-\frac{lx}{2h}}^{\frac{lx}{2h}}x^2 + y^2 \diff y\diff x\\
&= 2\rho \int_0^h\int_0^{\frac{lx}{2h}} x^2 + y^2 \diff y\diff x\\
&= 2\rho \int_0^h \Biggl[x^2y + \frac{1}{3} y^3\Biggr]_0^{\frac{lx}{2h}} \diff x\\
&= 2\rho \int_0^h x^2 \frac{lx}{2h} + \frac{1}{3} \frac{l^3x^3}{8h^3} \diff x\\
&= 2\rho \left(\frac{l}{2h} + \frac{l^3}{24h^3}\right) \int_0^h x^3 \diff x\\
&= 2\rho \left(\frac{l}{2h} + \frac{l^3}{24h^3}\right) \Biggl[ \frac{1}{4} x^4\Biggr]_0^h \\
&= \frac{h^4\rho}{2} \left(\frac{l}{2h} + \frac{l^3}{24h^3}\right) \\
&= \frac{\rho lh^3}{4} \left(1 + \frac{l^2}{12h^2}\right) \\
&= \frac{m_T h^2}{2} \left(1 + \frac{l^2}{12h^2}\right) \\
&= \frac{m_T}{2} \frac{l^2}{4 \tan^2\left(\frac{\theta}{2}\right)}\left(1 + \frac{4 \tan^2\left(\frac{\theta}{2}\right)}{12}\right) \\
&= \frac{m_Tl^2}{24} \left(1 + 3\cot^2\left(\frac{\theta}{2}\right)\right)
\end{split}
\end{equation}

View File

@ -1 +1,167 @@
\section{Theoretical Background}
The theoretical background is everything related to the physics part of the
project. It covers the calculating the inertia of different types of polygons;
different algorithms to detect whether there is a collision between two
polygons; the resolution of the collision, i.e. finding the final
velocity vectors and angular speed of those polygons.
\subsection{Moment of inertia}
The inertia of an object refers to the tendency of an object to resist a change
of its state of motion or rest, it describes how the object behaves when forces
are applied to it. An object with a lot of inertia requires more force to change
its motion, either to make it move if it's at rest or to stop it if it's already
moving. On the other hand, an object with less inertia is easier to set in
motion or bring to a halt.
The moment of inertia is similar but is used in a slightly different context, it
specifically refers to the rotational inertia of an object. It measures an
object's resistance to changes in its rotational motion and how its mass is
distributed with respect to is axis of rotation.
In the case of this project the axis of rotation is the one along the $z$-axis
(perpendicular to the plane of the simulation) and placed at the barycenter of
the polygon.
The general formula for the moment of inertia is
$$ I_Q = \int \vec r^2 \rho(\vec r) \diff A $$
where $\rho$ is the density of object $Q$ in the point $\vec r$ across the
small pieces of area $A$ of the object.
In our case, since we are implementing a 2D engine we can use the $\mathbb{R}^2$
coordinate systems, thus the formula becomes
$$ I_Q = \iint \rho(x, y) \vec r^2 \diff x\diff y$$
and since the requirements express that the mass of the polygons is spread
uniformly across its surface, the formula finally becomes
\begin{equation}
\label{eq:moment}
I_Q = \rho \iint x^2 + y^2 \diff x\diff y
\end{equation}
The bounds of the integral depend on the shape of the polygon. In the following
sections, we will describe how to compute those bounds, then we will show a
different technique to compute the moment of inertia of arbitrary polygons.
\subsubsection{Rectangle}
The moment of inertia of a rectangle of width $w$ and height $h$ with respect to
the axis of rotation that passes through its barycenter can be visualized in the
\figref{fig:rectangle_inertia}.
\begin{figure}[H]
\centering
\hfill
\begin{subfigure}[]{.4\textwidth}
\centering
\inputtikz{rectangle_inertia2d}
\caption{2d view of rectangle with axis of rotation}
\label{fig:rectangle_inertia2d}
\end{subfigure}
\hfill
\begin{subfigure}[]{.4\textwidth}
\centering
\inputtikz{rectangle_inertia3d}
\caption{3d view of rectangle with axis of rotation}
\label{fig:rectangle_inertia3d}
\end{subfigure}
\hfill\null
\caption{Representation of rectangle with respect to axis of rotation $z$}
\label{fig:rectangle_inertia}
\end{figure}
As figure \figref{fig:rectangle_inertia2d} implies, the bounds of equation
\ref{eq:moment} are trivial to derive:
\begin{equation}
\label{eq:rect_moment}
I_{\text{rect}} = \rho \int_{-\frac{h}{2}}^{\frac{h}{2}}
\int_{-\frac{w}{2}}^{\frac{w}{2}} x^2 + y^2 \diff x \diff y
= \frac{\rho wh}{12} \left( w^2 + h^2 \right)
\end{equation}
and since $\rho w h$ is the density of the rectangle multiplied by its area, we
can replace this term by its mass $m$, thus
\begin{equation}
I_{\text{rect}} = \frac{1}{12} m\left(w^2 + h^2\right)
\end{equation}
All the steps to compute equation~\ref{eq:rect_moment} can be found in equation
\ref{eq:rect_moment_long} in Appendix \ref{appendix:calculations}.
\subsubsection{Regular Polygons}
A regular polygon is a shape that has sides of equal length and angles between
those sides of equal measure. A polygon of $n$ sides can be subdivided in $n$
congruent (and isosceles since they are all the radius of the circumscribing
circle) triangles that all meet in the polygon's barycenter,
as demonstrated in Figure \ref{fig:pentagon_triangles} with a pentagon.
\begin{figure}[H]
\centering
\hfill
\begin{subfigure}[]{.45\textwidth}
\centering
\inputtikz[.6]{pentagon}
\caption{Regular polygon of 5 sides with its barycenter}
\label{fig:pentagon}
\end{subfigure}
\hfill
\begin{subfigure}[]{.45\textwidth}
\centering
\inputtikz[.6]{pentagon_congruent}
\caption{Pentagon divided in 5 congruent triangles}
\label{fig:pentagon_triangles}
\end{subfigure}
\hfill\null
\caption{Subdivision of regular polygons into congruent triangles}
\label{fig:regular_poly}
\end{figure}
If we define one of the sub-triangle of the regular polygon as $T$, then we can
find the moment of inertia $I_T$ when it is rotating about the barycenter. To
find the bounds of the integral in equation \ref{eq:moment}, we can take the
triangle $T$ and place it along the $x$-axis so that it is symmetric likes shown
in figure. Assuming the side length of the polygon is $l$, the height of the
triangle $T$ is $h$ and the angle of the triangle on the barycenter of the
polygon to be $\theta$, then
\begin{figure}[H]
\centering
\inputtikz[.3]{isosceles}
\caption{Sub-triangle $T$ of regular polygon}
\label{fig:subtriangle}
\end{figure}
we can see the bounds for the integral
\begin{equation}
\label{eq:subtriangle_moment}
I_{T} = \rho \int_0^h\int_{-\frac{lx}{2h}}^{\frac{lx}{2h}}x^2 + y^2 \diff
y\diff x= \frac{m_Tl^2}{24} \left(1 + 3\cot^2\left(\frac{\theta}{2}\right)\right)
\end{equation}
All the steps to compute equation~\ref{eq:subtriangle_moment} can be found in
equation \ref{eq:subtriangle_moment_long} in Appendix
\ref{appendix:calculations}.
Now that we have the moment of inertia of the sub-triangle, we can make the link
to the overall polygon. Since
$$ \theta = \frac{2\pi}{n} \implies \frac{\theta}{2} = \frac{\pi}{n} $$
and the moment of inertia are additive (as long they are as they are about the same
axis) we can get the moment of inertia with
$$ I_{\text{regular}} = n I_T $$
and since the mass of the regular polygon $m$ is the sum of the masses of the
sub-triangle
$$ m = n m_T $$
we have that
\begin{equation}
\label{eq:regular_moment}
I_{\text{regular}} = \frac{ml^2}{24} \left( 1 + 3\cot^2\left(\frac{\pi}{n}\right) \right)
\end{equation}
\subsubsection{Arbitrary Polygons}
\subsection{Collision detection}
\subsubsection{Separating Axis Theorem}
\subsubsection{Vertex collisions}
\subsection{Collision resolution}
\label{sub:resolution}
\cite{collision:resolution}
\subsubsection{Physics}
\subsubsection{Solving for the impulse parameter}

29
tikzs/isosceles.tikz Normal file
View File

@ -0,0 +1,29 @@
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (0, -4) {};
\node [style=none] (1) at (0, 4) {};
\node [style=none] (2) at (-1, 0) {};
\node [style=none] (3) at (8, 0) {};
\node [style=none] (4) at (0, 0) {};
\node [style=none] (5) at (6, 3) {};
\node [style=none] (6) at (6, -3) {};
\node [style=none] (7) at (6.5, -0.5) {\huge$h$};
\node [style=none] (8) at (-0.5, 3) {\huge$\frac{l}{2}$};
\node [style=none] (9) at (-0.75, -3) {\huge$-\frac{l}{2}$};
\node [style=none] (10) at (0, 3) {};
\node [style=none] (11) at (0, -3) {};
\node [style=none] (12) at (8, -0.25) {\Large$x$};
\node [style=none] (13) at (0.5, 4) {\Large$y$};
\node [style=none] (14) at (2, .5) {\Large$\frac{\theta}{2}$};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw [style=Axis] (0.center) to (1.center);
\draw [style=Axis] (2.center) to (3.center);
\draw (4.center) to (5.center);
\draw (5.center) to (6.center);
\draw (6.center) to (4.center);
\draw [style=Dashed] (5.center) to (10.center);
\draw [style=Dashed] (11.center) to (6.center);
\tkzMarkAngle[size=1.5cm](3,4,5);
\end{pgfonlayer}
\end{tikzpicture}

22
tikzs/pentagon.tikz Normal file
View File

@ -0,0 +1,22 @@
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (0, 4) {};
\node [style=none] (1) at (3.804, 1.236) {};
\node [style=none] (2) at (2.352, -3.236) {};
\node [style=none] (3) at (-2.352, -3.236) {};
\node [style=none] (4) at (-3.804, 1.236) {};
\node [style=Medium dot] (5) at (0, 0) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw[thick] (3.center) to (2.center);
\draw[thick] (2.center) to (1.center);
\draw[thick] (1.center) to (0.center);
\draw[thick] (0.center) to (4.center);
\draw[thick] (4.center) to (3.center);
% \foreach \i in {0, ..., 5}{
% \draw (5.center) to (\i.center);
% \tkzMarkSegment[pos=.5,mark=||](5,\i);
% }
\end{pgfonlayer}
\end{tikzpicture}

View File

@ -0,0 +1,29 @@
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (0, 4) {};
\node [style=none] (1) at (3.804, 1.236) {};
\node [style=none] (2) at (2.352, -3.236) {};
\node [style=none] (3) at (-2.352, -3.236) {};
\node [style=none] (4) at (-3.804, 1.236) {};
\node [style=Big dot] (5) at (0, 0) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw[thick] (3.center) to (2.center);
\draw[thick] (2.center) to (1.center);
\draw[thick] (1.center) to (0.center);
\draw[thick] (0.center) to (4.center);
\draw[thick] (4.center) to (3.center);
\foreach \i in {0, ..., 5}{
\draw (5.center) to (\i.center);
\tkzMarkSegment[pos=.5,mark=|](5,\i);
}
\tkzMarkAngle[mark=||](1,5,0);
\tkzMarkAngle[mark=||](2,5,1);
\tkzMarkAngle[mark=||](3,5,2);
\tkzMarkAngle[mark=||](4,5,3);
\tkzMarkAngle[mark=||](0,5,4);
\node [draw] at (5.center) [circle through={(0.center)}]{};
\end{pgfonlayer}
\end{tikzpicture}

View File

@ -0,0 +1,31 @@
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (-3, 2) {};
\node [style=none] (1) at (-3, -2) {};
\node [style=none] (2) at (3, -2) {};
\node [style=none] (3) at (3, 2) {};
\node [style=Circle] (4) at (-1.25, 0) {};
\node [style=Dot] (7) at (-1.25, 0) {};
\node [style=none] (10) at (-1.75, 0) {$z$};
\node [style=none] (11) at (0, 4) {};
\node [style=none] (12) at (4, 0) {};
\node [style=none] (13) at (0.5, 4) {$y$};
\node [style=none] (14) at (4, 0.5) {$x$};
\node [style=none] (15) at (-0.5, 0) {};
\node [style=none] (16) at (0, -0.5) {};
\node [style=none] (17) at (-3, -2.5) {$\left(-\frac{w}{2}, -\frac{h}{2}\right)$};
\node [style=none] (18) at (3, 2.5) {$\left(\frac{w}{2}, \frac{h}{2}\right)$};
\node [style=Medium dot] (19) at (3, 2) {};
\node [style=Medium dot] (20) at (-3, -2) {};
\node [style=none] (21) at (-5, 5) {};
\node [style=none] (22) at (5, -3) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (0.center) to (1.center);
\draw (1.center) to (2.center);
\draw (2.center) to (3.center);
\draw (3.center) to (0.center);
\draw [style=Axis] (16.center) to (11.center);
\draw [style=Axis] (15.center) to (12.center);
\end{pgfonlayer}
\end{tikzpicture}

View File

@ -0,0 +1,32 @@
\begin{tikzpicture}
\begin{pgfonlayer}{nodelayer}
\node [style=none] (0) at (-1.5, 1.5) {};
\node [style=none] (1) at (-4.5, -1.5) {};
\node [style=none] (2) at (1.5, -1.5) {};
\node [style=none] (3) at (4.5, 1.5) {};
\node [style=none] (10) at (-0.5, 4) {$z$};
\node [style=none] (11) at (2, 2) {};
\node [style=none] (12) at (4, 0) {};
\node [style=none] (13) at (1.5, 2) {$y$};
\node [style=none] (14) at (4, -0.5) {$x$};
\node [style=none] (15) at (-0.25, 0) {};
\node [style=none] (16) at (-0.25, -0.25) {};
\node [style=none] (17) at (-4.5, -2) {$\left(-\frac{w}{2}, -\frac{h}{2}\right)$};
\node [style=none] (18) at (4.5, 2) {$\left(\frac{w}{2}, \frac{h}{2}\right)$};
\node [style=Medium dot] (19) at (4.5, 1.5) {};
\node [style=Medium dot] (20) at (-4.5, -1.5) {};
\node [style=none] (21) at (0, -0.25) {};
\node [style=none] (22) at (0, 4) {};
\node [style=none] (23) at (-5, 5) {};
\node [style=none] (24) at (5, -3) {};
\end{pgfonlayer}
\begin{pgfonlayer}{edgelayer}
\draw (0.center) to (1.center);
\draw (1.center) to (2.center);
\draw (2.center) to (3.center);
\draw (3.center) to (0.center);
\draw [style=Axis] (16.center) to (11.center);
\draw [style=Axis] (15.center) to (12.center);
\draw [style=Axis] (21.center) to (22.center);
\end{pgfonlayer}
\end{tikzpicture}

14
tikzs/styles.tikzstyles Normal file
View File

@ -0,0 +1,14 @@
% TiKZ style file generated by TikZiT. You may edit this file manually,
% but some things (e.g. comments) may be overwritten. To be readable in
% TikZiT, the only non-comment lines must be of the form:
% \tikzstyle{NAME}=[PROPERTY LIST]
% Node styles
\tikzstyle{Circle}=[fill=none, draw=black, shape=circle]
\tikzstyle{Dot}=[fill=black, draw=black, shape=circle, minimum size=1pt, inner sep=0, outer sep=0]
\tikzstyle{Medium dot}=[fill=black, draw=black, shape=circle, minimum size=2pt, inner sep=0, outer sep=0]
\tikzstyle{Big dot}=[fill=black, draw=black, shape=circle, minimum size=3pt, inner sep=0, outer sep=0]
% Edge styles
\tikzstyle{Axis}=[draw=black, ->]
\tikzstyle{Dashed}=[-,dashed, style = dotted]