-
Notifications
You must be signed in to change notification settings - Fork 0
/
ps3.tex
43 lines (33 loc) · 2.76 KB
/
ps3.tex
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
\section{PS3: Pythagoras Tree}\label{sec:ps3}
\graphicspath{{ps3b}}
\subsection{Discussion:}\label{sec:ps3b:disc}
The assignment's objective was the create a primary function that recursively drew a fractal like image. Fractals are dictated by their self-similarity, and in this drawing, at the top of each square the triangle is drawn.
Whereby each triangle can make two more squares. The recursive function has a base case, which allows for setting a finite limit on the number of calls. In our assignment, we were able to first create a function that worked for the 45 degree
triangle, then afterwards we implemented the function for all angles between 1-89. We then added a coloring scheme that spanned the amount of function calls.
The extra credit feature we implemented was slightly changing the function so that it could operate with any starting angle, not just 45 degrees.
The was done by fixing some aspects of the first algorithm so that they were more abstract and not specifically catered towards 45 degrees.
One feature I implemented was forming a mapping from the cartesian coordinates into the video window coordinates. The dx and dy were conceptually born from the understanding of cosine and sin in
the cartesian plane, so the mapping made the entire problem much easier.
Lastly the coloring was implemented with two different methods, one of logarithmic and one linear.
\subsection{Key algorithms, Data structures and OO Designs used in this Assignment:}
A key data structure in the assignment was a vector of rectangles. This was essential because it allowed us to create rectangles for each function call and store them all in a central data structure.
Afterwards the draw feature could very easily display all the rectangles that were pushed into the vector.
\subsection{What I learned :}
I learned the difficulty in using parametric functions that are catered to euclidean space which treats the 2 dimensional plane of real numbers. In the SFML library the top left is 0 and everything else is positive. As mentioned prior, this was overcome with a mapping into euclidean space instead of trying to reconfigure the trigonometric functions for the strange orientation.
\subsection{Codebase}\label{sec:ps3:code}
\textbf{\colorbox{pink}{Makefile}} \newline \textbf{This Makefile has no Linting as the program does not have any lints.}
\lstinputlisting[language=Make]{ps3/Makefile}
\textbf{\colorbox{pink}{main.cpp}}
\lstinputlisting{ps3/main.cpp}
\textbf{\colorbox{pink}{PTree.h}}
\lstinputlisting{ps3/PTree.h}
\textbf{\colorbox{pink}{PTree.cpp}}
\lstinputlisting{ps3/PTree.cpp}
\subsection{Output:}
\begin{figure}[h]
\centering
\includegraphics[width=0.69\textwidth]{projectPictures/ps3.png}
\caption{PS3 Output Window}
\label{fig:ps3}
\end{figure}
\newpage