Finishing Report

This commit is contained in:
Noah L. Schrick 2022-03-09 22:15:04 -06:00
parent 53633be3f6
commit cafc2628aa
8 changed files with 143 additions and 37 deletions

View File

@ -1,6 +1,18 @@
\relax \relax
\@writefile{toc}{\contentsline {section}{\numberline {1}Problem Introduction}{1}{}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {1}Problem Introduction}{1}{}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {2}Program Preface}{2}{}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {2}Program Preface}{2}{}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3}Coding Approach}{3}{}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {3}Programming Approach}{3}{}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4}Results}{3}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.1}Line Class}{3}{}\protected@file@percent }
\gdef \@abspage@last{3} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2}HiddenLines Class}{3}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.2.1}Constructing the Problem}{4}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.2.2}Generating the Solution}{4}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.2.3}Printing the solution}{4}{}\protected@file@percent }
\newlabel{sec:print}{{3.2.3}{4}}
\@writefile{toc}{\contentsline {section}{\numberline {4}Results}{5}{}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Path Walking to State 14}}{5}{}\protected@file@percent }
\newlabel{fig:term}{{1}{5}}
\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces Path Walking to State 14}}{6}{}\protected@file@percent }
\newlabel{fig:orig}{{2}{6}}
\@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces Path Walking to State 14}}{7}{}\protected@file@percent }
\newlabel{fig:sol}{{3}{7}}
\gdef \@abspage@last{7}

View File

@ -1,4 +1,4 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021/Arch Linux) (preloaded format=pdflatex 2022.2.14) 9 MAR 2022 21:14 This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021/Arch Linux) (preloaded format=pdflatex 2022.2.14) 9 MAR 2022 22:12
entering extended mode entering extended mode
restricted \write18 enabled. restricted \write18 enabled.
%&-line parsing enabled. %&-line parsing enabled.
@ -115,40 +115,57 @@ LaTeX Font Info: External font `cmex10' loaded for size
LaTeX Font Info: External font `cmex10' loaded for size LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line 15. (Font) <6> on input line 15.
(./Schrick-Noah_CS-7353_HW4.toc) (./Schrick-Noah_CS-7353_HW4.toc
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line 4.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line 4.
)
\tf@toc=\write3 \tf@toc=\write3
\openout3 = `Schrick-Noah_CS-7353_HW4.toc'. \openout3 = `Schrick-Noah_CS-7353_HW4.toc'.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line 25.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line 25.
[1 [1
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] [2] [3] (./Schrick-Noah_CS {/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] [2] [3] [4]
-7353_HW4.aux) ) <./images/term.png, id=25, 621.32124pt x 595.22375pt>
File: ./images/term.png Graphic file (type png)
<use ./images/term.png>
Package pdftex.def Info: ./images/term.png used on input line 138.
(pdftex.def) Requested size: 345.0pt x 330.50749pt.
<./images/orig.png, id=26, 635.37375pt x 481.8pt>
File: ./images/orig.png Graphic file (type png)
<use ./images/orig.png>
Package pdftex.def Info: ./images/orig.png used on input line 145.
(pdftex.def) Requested size: 345.0pt x 261.6164pt.
<./images/sol.png, id=27, 639.38875pt x 477.785pt>
File: ./images/sol.png Graphic file (type png)
<use ./images/sol.png>
Package pdftex.def Info: ./images/sol.png used on input line 152.
(pdftex.def) Requested size: 345.0pt x 257.8032pt.
[5 <./images/term.png>] [6 <./images/orig.png>] [7 <./images/sol.png>] (./Schr
ick-Noah_CS-7353_HW4.aux) )
Here is how much of TeX's memory you used: Here is how much of TeX's memory you used:
1414 strings out of 478353 1446 strings out of 478353
23513 string characters out of 5854635 24104 string characters out of 5854635
326485 words of memory out of 5000000 325521 words of memory out of 5000000
19564 multiletter control sequences out of 15000+600000 19591 multiletter control sequences out of 15000+600000
407713 words of font info for 41 fonts, out of 8000000 for 9000 408020 words of font info for 42 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191 1141 hyphenation exceptions out of 8191
55i,6n,62p,225b,193s stack positions out of 5000i,500n,10000p,200000b,80000s 55i,6n,62p,225b,237s stack positions out of 5000i,500n,10000p,200000b,80000s
{/usr/share/texmf-dist/fonts/enc/dvips/cm-super/cm-super-ts1.en {/usr/share/texmf-dist/fonts/enc/dvips/cm-super/cm-s
c}</usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb></usr/share/ uper-ts1.enc}</usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb><
texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/share/texmf-dist/fon /usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/share/tex
ts/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texmf-dist/fonts/type1/publi mf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texmf-dist/fonts/
c/amsfonts/cm/cmmi7.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/c type1/public/amsfonts/cm/cmmi7.pfb></usr/share/texmf-dist/fonts/type1/public/am
mr10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/ sfonts/cm/cmr10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12
share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb></usr/share/texmf-dis .pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb></usr/shar
t/fonts/type1/public/amsfonts/cm/cmr7.pfb></usr/share/texmf-dist/fonts/type1/pu e/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb></usr/share/texmf-dist/fon
blic/amsfonts/cm/cmsy10.pfb></usr/share/texmf-dist/fonts/type1/public/cm-super/ ts/type1/public/amsfonts/cm/cmsy10.pfb></usr/share/texmf-dist/fonts/type1/publi
sfrm1000.pfb> c/cm-super/sfrm1000.pfb>
Output written on Schrick-Noah_CS-7353_HW4.pdf (3 pages, 117959 bytes). Output written on Schrick-Noah_CS-7353_HW4.pdf (7 pages, 199968 bytes).
PDF statistics: PDF statistics:
65 PDF objects out of 1000 (max. 8388607) 82 PDF objects out of 1000 (max. 8388607)
39 compressed objects within 1 object stream 49 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000) 0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000) 16 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file not shown.

View File

@ -20,7 +20,8 @@ The Hidden Surface Problem is widely used in computer graphics. When displaying
not all images should be visible (for example, if one object is in front of another). not all images should be visible (for example, if one object is in front of another).
To avoid overlapping images from being displayed and causing collisions, computations are To avoid overlapping images from being displayed and causing collisions, computations are
performed to remove all or parts of an object from the field of vision. performed to remove all or parts of an object from the field of vision.
This problem is a simplified version focusing on lines in a 2D plane. Rather than handling shifting This problem is a simplified version focusing on linear lines in a 2D plane.
Rather than handling shifting
perspectives, this problem will be further simplified to perspectives, this problem will be further simplified to
focus on the perspective as looking down from y=$\infty$. focus on the perspective as looking down from y=$\infty$.
@ -76,11 +77,82 @@ does not alter the solution computation.
In addition, this program promises no guarantee of working on other Operating Systems - In addition, this program promises no guarantee of working on other Operating Systems -
no testing was conducted on any other platform besides the local Linux machine. no testing was conducted on any other platform besides the local Linux machine.
\section{Programming Approach}
\subsection{Line Class}
To aid in the derivation of the solution, the first step was to create a Line class.
This class has members of slope, y-intercept, an ID, the x-value at which visibility starts,
and the x-value at which visibility ends. The ID is associated with the order from the CSV file,
and the visibility values are both initialized to 0.
Functions included with this class are getters and setters for various members, and
operator overloads for == and $<$ to aid in the sorting of Lines based on slope when using sets.
Also included is a function to find the x-value of the intersection between two lines.
\subsection{HiddenLines Class}
A separate class was created for handling the problem space. The HiddenLines class contains
few members of its own, and is primarily function-based. The single member that this class
has is a vector of all lines for the given problem.
This class contains four functions: a function to construct the problem, a function to get
the vector of lines, a function to generate the solution, and a function to print the solution.
\subsubsection{Constructing the Problem}
For modularity, this problem uses a CSV file for constructing the problem. Any and all lines can
be stored in a CSV file in the data folder. This CSV file is of format (slope,y-intercept).
This file is read and parsed, then inserted into a set to order the lines by slope. After
all lines are imported, the set is then copied to a vector for ease of use for other functions.
Basic error checking is performed only in the sense of ensuring that there are the same number
of slopes and y-intercept entries.
\subsubsection{Generating the Solution}
This problem uses a divide-and-conquer approach. The base cases are for line vectors of size 1 or 2.
When a line vector is of size 1, it is returned with no further computation. When a line vector is
of size 2, the two lines have their slopes compared and their intersection point found. The line
with the smallest slope is visible up until the intersection point, and the line with the greater
slope is visible starting at the intersection point. The lines have their underlying visibility
range members adjusted, and they are returned to be merged with the other divided half.
The merge process walks through each halved list and compares lines between the halves.
The lines between the vectors have their slopes and intersection points compared, similar to the
aforementioned process, but a separate function for removing the invisible lines is also called
after the halves are merged. The removal process returns a new vector container that only
holds the visible lines, after further comparisons of lines and intersection points.
\subsubsection{Printing the solution} \label{sec:print}
The solution is printed by walking through the final container and printing each line's
ID, their visibility start point, and their visibility end point. If the start or end point
is the maximum or minimum value of a double, then it is converted to a string of positive
or negative infinity, respectively. In addition, GNUPlot prints the original problem space,
and the final visible lines. As a note, extra work is needed to convert the final solution
to a piecewise plot. At the current moment, all lines that are visible are printed across
the entire domain, rather than their restricted domain.
\section{Coding Approach}
3
\section{Results} \section{Results}
4 Figure \ref{fig:term} shows the output of the terminal after the program completes.
This solution was manually verified with Desmos by plotting each line and comparing
their intersections. Figure \ref{fig:orig} displays the plotting of the original problem
with GNUPlot. Figure \ref{fig:sol} displays the plotting of the only visible lines, though
as mentioned in Section \ref{sec:print}, further work needs to be conducted to plot the
piecewise functions correctly.
\begin{figure}[htp]
\includegraphics[width=\linewidth]{"./images/term.png"}
\vspace{.2truein} \centerline{}
\caption{Path Walking to State 14}
\label{fig:term}
\end{figure}
\begin{figure}[htp]
\includegraphics[width=\linewidth]{"./images/orig.png"}
\vspace{.2truein} \centerline{}
\caption{Path Walking to State 14}
\label{fig:orig}
\end{figure}
\begin{figure}[htp]
\includegraphics[width=\linewidth]{"./images/sol.png"}
\vspace{.2truein} \centerline{}
\caption{Path Walking to State 14}
\label{fig:sol}
\end{figure}
\end{document} \end{document}

View File

@ -1,4 +1,9 @@
\contentsline {section}{\numberline {1}Problem Introduction}{1}{}% \contentsline {section}{\numberline {1}Problem Introduction}{1}{}%
\contentsline {section}{\numberline {2}Program Preface}{2}{}% \contentsline {section}{\numberline {2}Program Preface}{2}{}%
\contentsline {section}{\numberline {3}Coding Approach}{3}{}% \contentsline {section}{\numberline {3}Programming Approach}{3}{}%
\contentsline {section}{\numberline {4}Results}{3}{}% \contentsline {subsection}{\numberline {3.1}Line Class}{3}{}%
\contentsline {subsection}{\numberline {3.2}HiddenLines Class}{3}{}%
\contentsline {subsubsection}{\numberline {3.2.1}Constructing the Problem}{4}{}%
\contentsline {subsubsection}{\numberline {3.2.2}Generating the Solution}{4}{}%
\contentsline {subsubsection}{\numberline {3.2.3}Printing the solution}{4}{}%
\contentsline {section}{\numberline {4}Results}{5}{}%

BIN
images/orig.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
images/sol.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
images/term.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB