diff options
| -rw-r--r-- | geometry/geometry.tex | 3 | ||||
| -rw-r--r-- | geometry/lines.cpp | 37 | ||||
| -rw-r--r-- | math/math.tex | 12 | ||||
| -rw-r--r-- | tcr.pdf | bin | 243173 -> 170218 bytes | |||
| -rw-r--r-- | tcr.tex | 5 |
5 files changed, 57 insertions, 0 deletions
diff --git a/geometry/geometry.tex b/geometry/geometry.tex index 6192c6e..b48a51e 100644 --- a/geometry/geometry.tex +++ b/geometry/geometry.tex @@ -3,5 +3,8 @@ \subsection{Closest Pair} \lstinputlisting{geometry/closestPair.cpp} +\subsection{Geraden} +\lstinputlisting{geometry/lines.cpp} + \subsection{Formeln - \lstinline{std::complex}} \lstinputlisting{geometry/formulars.cpp}
\ No newline at end of file diff --git a/geometry/lines.cpp b/geometry/lines.cpp new file mode 100644 index 0000000..ec6fdde --- /dev/null +++ b/geometry/lines.cpp @@ -0,0 +1,37 @@ +struct pt { //complex<double> does not work here, becuase we need to set pt.x and pt.y + double x, y; + pt() {}; + pt(double x, double y) : x(x), y(y) {}; +}; + +struct line { + double a, b, c; //a*x+b*y+c, b=0 <=> vertical line, b=1 <=> otherwise +}; + +line pointsToLine(pt p1, pt p2) { + line l; + if (fabs(p1.x - p2.x) < EPSILON) { + l.a = 1; l.b = 0.0; l.c = -p1.x; + } else { + l.a = -(double)(p1.y - p2.y) / (p1.x - p2.x); + l.b = 1.0; + l.c = -(double)(l.a * p1.x) - p1.y; + } + return l; +} + +bool areParallel(line l1, line l2) { + return (fabs(l1.a - l2.a) < EPSILON) && (fabs(l1.b - l2.b) < EPSILON); +} + +bool areSame(line l1, line l2) { + return areParallel(l1, l2) && (fabs(l1.c - l2.c) < EPSILON); +} + +bool areIntersect(line l1, line l2, pt &p) { + if (areParallel(l1, l2)) return false; + p.x = (l2.b * l1.c - l1.b * l2.c) / (l2.a * l1.b - l1.a * l2.b); + if (fabs(l1.b) > EPSILON) p.y = -(l1.a * p.x + l1.c); + else p.y = -(l2.a * p.x + l2.c); + return true; +}
\ No newline at end of file diff --git a/math/math.tex b/math/math.tex index 0b66163..f82ab65 100644 --- a/math/math.tex +++ b/math/math.tex @@ -4,5 +4,17 @@ \lstinputlisting{math/gcd-lcm.cpp} \lstinputlisting{math/extendedEuclid.cpp} +\subsubsection{Multiplikatives Inverses von $x$ in $\mathbb{Z}/n\mathbb{Z}$} +Sei $0 \leq x < n$. Definiere $d := gcd(x, n)$. +\begin{description} + \item[Falls $d = 1$:] ~ + \begin{itemize}[nosep] + \item Erweiterter euklidischer Algorithmus liefert $\alpha$ und $\beta$ mit $\alpha x + \beta n = 1$ + \item Nach Kongruenz gilt $\alpha x + \beta n \equiv \alpha x \equiv 1 \mod n$ + \item $x^{-1} :\equiv \alpha \mod n$ + \end{itemize} + \item[Falls $d \neq 1$:] es existiert kein $x^{-1}$ +\end{description} + \subsection{Binomialkoeffizienten} \lstinputlisting{math/binomial.cpp}
\ No newline at end of file Binary files differ@@ -4,6 +4,11 @@ \usepackage[ngerman]{babel} \usepackage[utf8]{inputenc} +\usepackage{amsmath} +\usepackage{amssymb} + +\usepackage{enumitem} + \usepackage{color} \definecolor{darkred}{rgb}{0.72,0.07,0.07} \definecolor{darkgreen}{rgb}{0.23,0.62,0.22} |
