Sections 1 and 2 of the Report

This commit is contained in:
Noah L. Schrick 2022-03-09 21:16:21 -06:00
parent 0489683e68
commit 53633be3f6
16 changed files with 296 additions and 14 deletions

View File

@ -0,0 +1,6 @@
\relax
\@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 {3}Coding Approach}{3}{}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4}Results}{3}{}\protected@file@percent }
\gdef \@abspage@last{3}

View File

@ -0,0 +1,154 @@
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
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**Schrick-Noah_CS-7353_HW4
(./Schrick-Noah_CS-7353_HW4.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2021-11-22>
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
\c@part=\count183
\c@section=\count184
\c@subsection=\count185
\c@subsubsection=\count186
\c@paragraph=\count187
\c@subparagraph=\count188
\c@figure=\count189
\c@table=\count190
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
)
(/usr/share/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2021/09/16 v1.2d Enhanced LaTeX Graphics (DPC,SPQR)
(/usr/share/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks16
)
(/usr/share/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2021/03/04 v1.4d Standard LaTeX Graphics (DPC,SPQR)
(/usr/share/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2021/08/11 v1.11 sin cos tan (DPC)
)
(/usr/share/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 107.
(/usr/share/texmf-dist/tex/latex/graphics-def/pdftex.def
File: pdftex.def 2020/10/05 v1.2a Graphics/color driver for pdftex
))
\Gin@req@height=\dimen139
\Gin@req@width=\dimen140
)
(/usr/share/texmf-dist/tex/latex/base/inputenc.sty
Package: inputenc 2021/02/14 v1.3d Input encoding file
\inpenc@prehook=\toks17
\inpenc@posthook=\toks18
)
(/usr/share/texmf-dist/tex/latex/float/float.sty
Package: float 2001/11/08 v1.3d Float enhancements (AL)
\c@float@type=\count191
\float@exts=\toks19
\float@box=\box50
\@float@everytoks=\toks20
\@floatcapt=\box51
)
(/usr/share/texmf-dist/tex/latex/tools/indentfirst.sty
Package: indentfirst 1995/11/23 v1.03 Indent first paragraph (DPC)
)
(/usr/share/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
File: l3backend-pdftex.def 2021-12-14 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count192
\l__pdf_internal_box=\box52
)
(./Schrick-Noah_CS-7353_HW4.aux)
\openout1 = `Schrick-Noah_CS-7353_HW4.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 13.
LaTeX Font Info: ... okay on input line 13.
(/usr/share/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count193
\scratchdimen=\dimen141
\scratchbox=\box53
\nofMPsegments=\count194
\nofMParguments=\count195
\everyMPshowfont=\toks21
\MPscratchCnt=\count196
\MPscratchDim=\dimen142
\MPnumerator=\count197
\makeMPintoPDFobject=\count198
\everyMPtoPDFconversion=\toks22
) (/usr/share/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
85.
(/usr/share/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg
File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv
e
))
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <12> on input line 15.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <8> on input line 15.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line 15.
(./Schrick-Noah_CS-7353_HW4.toc)
\tf@toc=\write3
\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
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] [2] [3] (./Schrick-Noah_CS
-7353_HW4.aux) )
Here is how much of TeX's memory you used:
1414 strings out of 478353
23513 string characters out of 5854635
326485 words of memory out of 5000000
19564 multiletter control sequences out of 15000+600000
407713 words of font info for 41 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
55i,6n,62p,225b,193s stack positions out of 5000i,500n,10000p,200000b,80000s
{/usr/share/texmf-dist/fonts/enc/dvips/cm-super/cm-super-ts1.en
c}</usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb></usr/share/
texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/share/texmf-dist/fon
ts/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texmf-dist/fonts/type1/publi
c/amsfonts/cm/cmmi7.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/c
mr10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/
share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr17.pfb></usr/share/texmf-dis
t/fonts/type1/public/amsfonts/cm/cmr7.pfb></usr/share/texmf-dist/fonts/type1/pu
blic/amsfonts/cm/cmsy10.pfb></usr/share/texmf-dist/fonts/type1/public/cm-super/
sfrm1000.pfb>
Output written on Schrick-Noah_CS-7353_HW4.pdf (3 pages, 117959 bytes).
PDF statistics:
65 PDF objects out of 1000 (max. 8388607)
39 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file not shown.

View File

@ -0,0 +1,86 @@
\documentclass{article}
\usepackage{graphicx}
\graphicspath{ {./images/} }
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{indentfirst}
\setlength{\parskip}{\baselineskip}%
\title{CS 7353: Analysis of Algorithms Homework 4: Visible Lines Problem}
\author{Noah Schrick}
\date{March 8, 2022}
\begin{document}
\maketitle
\tableofcontents
\section{Problem Introduction}
The Hidden Surface Problem is widely used in computer graphics. When displaying images,
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
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
perspectives, this problem will be further simplified to
focus on the perspective as looking down from y=$\infty$.
The problem statement can be defined as follows:
You are given n nonvertical lines in the plane, labeled $L_{1}$,...,$L_{n}$,
with the ith line specified by the equation y=$a_{i}$x+$b_{i}$.
We will make the assumption that no three of the lines all meet at a single
point. We say line $L_{i}$ is uppermost at a given x-coordinate $x_{0}$ if its y-coordinate
at $x_{0}$ is greater than the y-coordinates of all the other lines at
$x_{0}$: $a_{i}$$x_{0}$+$b_{i}$>$a_{j}$$x_{0}$$b_{j}$ for all
j$\not=$i.
We say line $L_{i}$ is visible if there is some x-coordinate at which
it is uppermost-intuitively, some portion of it can be seen if you look down from "y=$\infty$".
Determine which lines are visible and at which restricted domains.
\section{Program Preface}
This assignment was given with instruction to implement this in C++, or justify why Python
should be used instead. This problem was solved using C++ on a Linux system.
Attached with submission is a zip folder that contains:
\begin{itemize}
\item{A CMakeLists.txt file for compiling}
\item{An "images" folder that contains:}
\begin{enumerate}
\item{Various images included in this report}
\end{enumerate}
\item{A "src" folder that contains:}
\begin{enumerate}
\item{A Line.cpp and Line.h file for the Line class and associated functions}
\item{A HiddenLines.cpp and HiddenLines.h file for the problem instance class and
associated functions}
\item{A GNUPlot .hpp file for plotting}
\item{The main file}
\end{enumerate}
\item{A "data" folder that contains:}
\begin{enumerate}
\item{A CSV file for defining the line functions to use}
\end{enumerate}
\item{A "build" folder that contains:}
\begin{enumerate}
\item{A build.sh script to simplify the build process}
\item{A run.sh script to simplify running the program}
\item{Various CMake files}
\item{The compiled binaries for the program and associated libraries}
\end{enumerate}
\end{itemize}
This program requires the installation of GNUPlot for plotting purposes,
but modification can be performed to remove the plotting. Removing the plotting
does not alter the solution computation.
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.
\section{Coding Approach}
3
\section{Results}
4
\end{document}

View File

@ -0,0 +1,4 @@
\contentsline {section}{\numberline {1}Problem Introduction}{1}{}%
\contentsline {section}{\numberline {2}Program Preface}{2}{}%
\contentsline {section}{\numberline {3}Coding Approach}{3}{}%
\contentsline {section}{\numberline {4}Results}{3}{}%

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -20,7 +20,23 @@ HL::HL()
}
//Print the solution and convert the double::max and double::lowest to inf strings
void print_sol(std::vector<Line>& lines){
void HL::print_sol(std::vector<Line>& lines){
HL inst = *this;
Gnuplot g1("lines");
g1.set_title("Original Lines");
g1.set_xrange(-20,20);
g1.set_yrange(-40,40);
Gnuplot g2("sol");
g2.set_title("Piecewise Solution");
g2.set_xrange(-20,20);
g2.set_yrange(-40,40);
for(Line line : inst.get_lines()){
g1.plot_slope(line.get_slope(),line.get_ycept(), "Line "+std::to_string(line.get_id()));
}
for(auto itr = lines.begin(); itr != lines.end(); itr++){
Line line = *itr;
double start_range = line.get_vis_start();
@ -37,7 +53,11 @@ void print_sol(std::vector<Line>& lines){
continue;
std::cout << "Line ID " << line.get_id() << " visible from x=" <<
start_print << " to x=" << stop_print << std::endl;
g2.plot_slope(line.get_slope(), line.get_ycept(), "Line "+std::to_string(line.get_id()));
}
g2.set_xrange(-20,20);
wait_for_key();
}
//Divide and Conquer Strategy using recursive call to divide ls and merge using merge()
@ -111,10 +131,6 @@ std::vector<Line> HL::construct_HWprob(){
//Set to hold all our Lines
std::set<Line> sorted_lines;
std::vector<Line> lines;
Gnuplot g1("lines");
g1.set_title("Original Lines");
g1.set_xrange(-20,20);
g1.set_yrange(-40,40);
//Hold our doubles from each line
std::vector<double> tmp_data;
@ -169,13 +185,9 @@ std::vector<Line> HL::construct_HWprob(){
line.set_vis_end(std::numeric_limits<double>::max());
*it = line;
}
g1.plot_slope(line.get_slope(),line.get_ycept(), "Line "+std::to_string(line.get_id()));
}
std::cout << "-----------------------------------------------------" << std::endl;
wait_for_key();
return lines;
}

View File

@ -12,15 +12,14 @@ class HL
std::vector<Line> gen_sol(std::vector<Line>& ls);
std::vector<Line> construct_HWprob();
std::vector<Line> get_lines();
void print_sol(std::vector<Line>& lines);
private:
std::vector<Line> lines;
};
std::vector<Line> merge(std::vector<Line> lh, std::vector<Line> rh);
void print_sol(std::vector<Line>& lines);
std::vector<Line> remove_invis(std::vector<Line> &merged);

View File

@ -2,13 +2,13 @@
#include "Line.h"
int Line::current_id = 0;
int Line::current_id = 1;
Line::Line(double x, double y)
{
set_slope(x);
set_ycept(y);
id = 0;
id = 1;
//Arbitrarily just say lines are visible starting at and ending at 0.
set_vis_start(0);

View File

@ -18,6 +18,6 @@ int main(int argc, char *argv[])
auto sol = inst.gen_sol(lines);
std::cout << "Solution is: " << std::endl;
print_sol(sol);
inst.print_sol(sol);
}

21
texput.log Normal file
View File

@ -0,0 +1,21 @@
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 20:36
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**Schrick-Noah_CS-7353
! Emergency stop.
<*> Schrick-Noah_CS-7353
End of file on the terminal!
Here is how much of TeX's memory you used:
3 strings out of 478353
127 string characters out of 5854635
295989 words of memory out of 5000000
18233 multiletter control sequences out of 15000+600000
403430 words of font info for 27 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
0i,0n,0p,23b,6s stack positions out of 5000i,500n,10000p,200000b,80000s
! ==> Fatal error occurred, no output PDF file produced!