\doxysection{Geometry.\+hpp}
\hypertarget{Geometry_8hpp_source}{}\label{Geometry_8hpp_source}\index{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/Geometry.hpp@{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/Geometry.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ }
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#ifndef\ GYM\_PCB\_GEOMETRY\_H}}
\DoxyCodeLine{00003\ \textcolor{preprocessor}{\#define\ GYM\_PCB\_GEOMETRY\_H}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#define\ CGAL\_DISABLE\_ROUNDING\_MATH\_CHECK}}
\DoxyCodeLine{00006\ }
\DoxyCodeLine{00007\ \textcolor{preprocessor}{\#include\ <iostream>}}
\DoxyCodeLine{00008\ \textcolor{preprocessor}{\#include\ "{}Defs.hpp"{}}}
\DoxyCodeLine{00009\ }
\DoxyCodeLine{00010\ \textcolor{comment}{//}}
\DoxyCodeLine{00011\ \textcolor{comment}{//\ CGAL\ configuration\ and\ type\ shorthands.}}
\DoxyCodeLine{00012\ \textcolor{comment}{//}}
\DoxyCodeLine{00013\ \textcolor{preprocessor}{\#include\ <CGAL/Bbox\_2.h>}}
\DoxyCodeLine{00014\ \textcolor{preprocessor}{\#include\ <CGAL/Polygon\_2.h>}}
\DoxyCodeLine{00015\ \textcolor{preprocessor}{\#include\ <CGAL/Simple\_cartesian.h>}}
\DoxyCodeLine{00016\ \textcolor{keyword}{typedef}\ CGAL::Simple\_cartesian<Real>\ Kernel;}
\DoxyCodeLine{00017\ }
\DoxyCodeLine{00018\ \textcolor{preprocessor}{\#if\ CGAL\_VERSION\_MAJOR\ >=\ 6}}
\DoxyCodeLine{00019\ \textcolor{preprocessor}{\#define\ std\_get\_for\_cgal\ std::get\_if}}
\DoxyCodeLine{00020\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00021\ \textcolor{preprocessor}{\#define\ std\_get\_for\_cgal\ boost::get}}
\DoxyCodeLine{00022\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00024\ \textcolor{keyword}{using\ }Vector\_2\ =\ Kernel::Vector\_2;}
\DoxyCodeLine{00025\ \textcolor{keyword}{using\ }Vector\_3\ =\ Kernel::Vector\_3;}
\DoxyCodeLine{00026\ \textcolor{keyword}{using\ }Point\_2\ =\ Kernel::Point\_2;}
\DoxyCodeLine{00027\ \textcolor{keyword}{using\ }Point\_3\ =\ Kernel::Point\_3;}
\DoxyCodeLine{00028\ \textcolor{keyword}{using\ }Direction\_2\ =\ Kernel::Direction\_2;}
\DoxyCodeLine{00029\ \textcolor{keyword}{using\ }Ray\_2\ =\ Kernel::Ray\_2;}
\DoxyCodeLine{00030\ \textcolor{keyword}{using\ }Ray\_3\ =\ Kernel::Ray\_3;}
\DoxyCodeLine{00031\ \textcolor{keyword}{using\ }Line\_2\ =\ Kernel::Line\_2;}
\DoxyCodeLine{00032\ \textcolor{keyword}{using\ }Segment\_2\ =\ Kernel::Segment\_2;}
\DoxyCodeLine{00033\ \textcolor{keyword}{using\ }Segment\_3\ =\ Kernel::Segment\_3;}
\DoxyCodeLine{00034\ \textcolor{keyword}{using\ }Triangle\_2\ =\ Kernel::Triangle\_2;}
\DoxyCodeLine{00035\ \textcolor{keyword}{using\ }Triangle\_3\ =\ Kernel::Triangle\_3;}
\DoxyCodeLine{00036\ \textcolor{keyword}{using\ }Circle\_2\ =\ Kernel::Circle\_2;}
\DoxyCodeLine{00037\ }
\DoxyCodeLine{00038\ \textcolor{keyword}{using\ }Bbox\_2\ =\ CGAL::Bbox\_2;}
\DoxyCodeLine{00039\ \textcolor{keyword}{using\ }Iso\_rectangle\_2\ =\ CGAL::Iso\_rectangle\_2<Kernel>;}
\DoxyCodeLine{00040\ \textcolor{keyword}{using\ }Polygon\_2\ =\ CGAL::Polygon\_2<Kernel>;}
\DoxyCodeLine{00041\ }
\DoxyCodeLine{00042\ \textcolor{keyword}{using\ }Aff\_transformation\_2\ =\ CGAL::Aff\_transformation\_2<Kernel>;}
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00044\ \textcolor{preprocessor}{\#include\ "{}Math/IPoint2.hpp"{}}}
\DoxyCodeLine{00045\ \textcolor{preprocessor}{\#include\ "{}Math/IPoint3.hpp"{}}}
\DoxyCodeLine{00046\ }
\DoxyCodeLine{00047\ \textcolor{keyword}{namespace\ }geo}
\DoxyCodeLine{00048\ \{}
\DoxyCodeLine{00049\ }
\DoxyCodeLine{00053\ \textcolor{keyword}{inline}\ Real\ cosine(\textcolor{keyword}{const}\ Vector\_2\ \&v1,\ \textcolor{keyword}{const}\ Vector\_2\ \&v2)}
\DoxyCodeLine{00054\ \{}
\DoxyCodeLine{00055\ \ \ \ \ \textcolor{keywordflow}{return}\ CGAL::scalar\_product(v1,\ v2)\ /\ std::sqrt(v1.squared\_length()\ *}
\DoxyCodeLine{00056\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ v2.squared\_length());}
\DoxyCodeLine{00057\ \}}
\DoxyCodeLine{00058\ }
\DoxyCodeLine{00063\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ distance45(\textcolor{keyword}{const}\ Point\_2\ \&A,\ \textcolor{keyword}{const}\ Point\_2\ \&B)}
\DoxyCodeLine{00064\ \{}
\DoxyCodeLine{00065\ \ \ \ \ \textcolor{keyword}{const}\ Real\ dx\ =\ std::abs(A.x()\ -\/\ B.x());}
\DoxyCodeLine{00066\ \ \ \ \ \textcolor{keyword}{const}\ Real\ dy\ =\ std::abs(A.y()\ -\/\ B.y());}
\DoxyCodeLine{00067\ \ \ \ \ \textcolor{keywordflow}{return}\ dx\ +\ dy\ -\/\ std::min(dx,\ dy)\ *\ (2.0\ -\/\ std::sqrt(2.0));}
\DoxyCodeLine{00068\ \ \ \ \ \textcolor{comment}{//\ return\ std::max(dx,\ dy)\ -\/\ std::min(dx,\ dy)\ +\ std::min(dx,\ dy)\ *\ std::sqrt(2.0);}}
\DoxyCodeLine{00069\ \ \ \ \ \textcolor{comment}{//\ return\ std::max(dx,\ dy)\ -\/\ std::min(dx,\ dy)\ *\ (1.0\ -\/\ std::sqrt(2.0));}}
\DoxyCodeLine{00070\ \}}
\DoxyCodeLine{00071\ }
\DoxyCodeLine{00075\ \textcolor{keyword}{inline}\ Bbox\_2\ bbox\_expanded\_abs(\textcolor{keyword}{const}\ Bbox\_2\ \&box,\ Real\ m)}
\DoxyCodeLine{00076\ \{}
\DoxyCodeLine{00077\ \ \ \ \ \textcolor{keywordflow}{return}\ Bbox\_2(box.xmin()\ -\/\ m,\ box.ymin()\ -\/\ m,\ box.xmax()\ +\ m,\ box.ymax()\ +\ m);}
\DoxyCodeLine{00078\ \}}
\DoxyCodeLine{00082\ \textcolor{keyword}{inline}\ Bbox\_2\ bbox\_expanded\_rel(\textcolor{keyword}{const}\ Bbox\_2\ \&box,\ Real\ r)}
\DoxyCodeLine{00083\ \{}
\DoxyCodeLine{00084\ \ \ \ \ \textcolor{keywordflow}{return}\ bbox\_expanded\_abs(box,\ std::max(box.xmax()\ -\/\ box.xmin(),\ box.ymax()\ -\/\ box.ymin())\ *\ r);}
\DoxyCodeLine{00085\ \}}
\DoxyCodeLine{00086\ }
\DoxyCodeLine{00087\ \textcolor{keyword}{inline}\ Bbox\_2\ bbox\_intersection(\textcolor{keyword}{const}\ Bbox\_2\ \&box1,\ \textcolor{keyword}{const}\ Bbox\_2\ \&box2)}
\DoxyCodeLine{00088\ \{}
\DoxyCodeLine{00089\ \ \ \ \ \textcolor{keywordflow}{return}\ Bbox\_2(std::max(box1.xmin(),\ box2.xmin()),}
\DoxyCodeLine{00090\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ std::max(box1.ymin(),\ box2.ymin()),}
\DoxyCodeLine{00091\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ std::min(box1.xmax(),\ box2.xmax()),}
\DoxyCodeLine{00092\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ std::min(box1.ymax(),\ box2.ymax()));}
\DoxyCodeLine{00093\ \}}
\DoxyCodeLine{00094\ }
\DoxyCodeLine{00095\ \textcolor{keyword}{inline}\ Real\ bbox\_area(\textcolor{keyword}{const}\ Bbox\_2\ \&box)}
\DoxyCodeLine{00096\ \{}
\DoxyCodeLine{00097\ \ \ \ \ \textcolor{keywordflow}{return}\ (box.xmax()\ -\/\ box.xmin())\ *\ (box.ymax()\ -\/\ box.ymin());}
\DoxyCodeLine{00098\ \}}
\DoxyCodeLine{00099\ }
\DoxyCodeLine{00100\ \textcolor{keyword}{inline}\ Real\ bbox\_diameter(\textcolor{keyword}{const}\ Bbox\_2\ \&box)}
\DoxyCodeLine{00101\ \{}
\DoxyCodeLine{00102\ \ \ \ \ \textcolor{keyword}{auto}\ dx\ =\ box.xmax()\ -\/\ box.xmin();}
\DoxyCodeLine{00103\ \ \ \ \ \textcolor{keyword}{auto}\ dy\ =\ box.ymax()\ -\/\ box.ymin();}
\DoxyCodeLine{00104\ \ \ \ \ \textcolor{keywordflow}{return}\ std::sqrt(dx\ *\ dx\ +\ dy\ *\ dy);}
\DoxyCodeLine{00105\ \}}
\DoxyCodeLine{00106\ }
\DoxyCodeLine{00107\ \textcolor{keyword}{inline}\ std::string\ to\_string(\textcolor{keyword}{const}\ Bbox\_2\ \&box)}
\DoxyCodeLine{00108\ \{}
\DoxyCodeLine{00109\ \ \ \ \ \textcolor{keywordflow}{return}\ fmt::format(\textcolor{stringliteral}{"{}\{:f\}\ \{:f\}\ \{:f\}\ \{:f\}"{}},\ box.xmin(),\ box.ymin(),\ box.xmax(),\ box.ymax());}
\DoxyCodeLine{00110\ \}}
\DoxyCodeLine{00111\ }
\DoxyCodeLine{00115\ \textcolor{keyword}{inline}\ Point\_2\ closest\_on(\textcolor{keyword}{const}\ Segment\_2\ \&s,\ \textcolor{keyword}{const}\ Point\_2\ \&o)}
\DoxyCodeLine{00116\ \{}
\DoxyCodeLine{00117\ \ \ \ \ \textcolor{keyword}{auto}\ x\ =\ s.supporting\_line().projection(o);}
\DoxyCodeLine{00118\ \ \ \ \ \textcolor{keywordflow}{if}\ (s.has\_on(x))}
\DoxyCodeLine{00119\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ x;}
\DoxyCodeLine{00120\ \ \ \ \ \textcolor{keywordflow}{return}\ (CGAL::squared\_distance(o,\ s.source())\ <}
\DoxyCodeLine{00121\ \ \ \ \ \ \ \ \ \ \ \ \ CGAL::squared\_distance(o,\ s.target()))\ ?\ s.source()\ :\ s.target();}
\DoxyCodeLine{00122\ \}}
\DoxyCodeLine{00123\ }
\DoxyCodeLine{00124\ \}\ \textcolor{comment}{//\ namespace\ geo}}
\DoxyCodeLine{00125\ }
\DoxyCodeLine{00126\ }
\DoxyCodeLine{00130\ \textcolor{keyword}{class\ }Point\_25}
\DoxyCodeLine{00131\ \{}
\DoxyCodeLine{00132\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00133\ \ \ \ \ Point\_25()\ \{\ \}}
\DoxyCodeLine{00134\ \ \ \ \ Point\_25(\textcolor{keyword}{const}\ Point\_2\ \&x,\ \textcolor{keywordtype}{int}\ z)\ :\ \_xy(x),\ \_z(z)\ \{\ \}}
\DoxyCodeLine{00135\ \ \ \ \ Point\_25(Real\ x,\ Real\ y,\ \textcolor{keywordtype}{int}\ z)\ :\ \_xy(x,y),\ \_z(z)\ \{\ \}}
\DoxyCodeLine{00136\ \ \ \ \ \textcolor{keyword}{const}\ Point\_2\&\ xy()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \_xy;\ \}}
\DoxyCodeLine{00137\ \ \ \ \ Real\ x()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \_xy.x();\ \}}
\DoxyCodeLine{00138\ \ \ \ \ Real\ y()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \_xy.y();\ \}}
\DoxyCodeLine{00139\ \ \ \ \ \textcolor{keywordtype}{int}\ z()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \_z;\ \}}
\DoxyCodeLine{00140\ \ \ \ \ Point\_25\ withZ(\textcolor{keywordtype}{int}\ z)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ Point\_25(\_xy,\ z);\ \}}
\DoxyCodeLine{00141\ \ \ \ \ Bbox\_2\ bbox()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \_xy.bbox();\ \}}
\DoxyCodeLine{00142\ \ \ \ \ Point\_25\&\ operator=(\textcolor{keyword}{const}\ Point\_25\ \&v)\ \{\ \_xy\ =\ v.\_xy;\ \_z\ =\ v.\_z;\ \textcolor{keywordflow}{return}\ *\textcolor{keyword}{this};\ \}}
\DoxyCodeLine{00143\ \ \ \ \ \textcolor{keywordtype}{bool}\ operator<(\textcolor{keyword}{const}\ Point\_25\ \&v)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ (\_z\ <\ v.\_z)\ ||\ (\_z\ ==\ v.\_z\ \&\&\ \_xy\ <\ v.\_xy);\ \}}
\DoxyCodeLine{00144\ \ \ \ \ \textcolor{keywordtype}{bool}\ operator==(\textcolor{keyword}{const}\ Point\_25\ \&v)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \_xy\ ==\ v.\_xy\ \&\&\ \_z\ ==\ v.\_z;\ \}}
\DoxyCodeLine{00145\ \ \ \ \ Point\_25\ operator+(\textcolor{keyword}{const}\ Vector\_2\ \&v)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ Point\_25(\_xy\ +\ v,\ \_z);\ \}}
\DoxyCodeLine{00146\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00147\ \ \ \ \ Point\_2\ \_xy;}
\DoxyCodeLine{00148\ \ \ \ \ \textcolor{keywordtype}{int}\ \_z;}
\DoxyCodeLine{00149\ \};}
\DoxyCodeLine{00150\ }
\DoxyCodeLine{00154\ \textcolor{keyword}{class\ }Segment\_25}
\DoxyCodeLine{00155\ \{}
\DoxyCodeLine{00156\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00157\ \ \ \ \ Segment\_25()\ \{\ \}}
\DoxyCodeLine{00158\ \ \ \ \ Segment\_25(\textcolor{keyword}{const}\ Segment\_2\ \&s,\ \textcolor{keywordtype}{int}\ layer\ =\ 0)\ :\ mS2(s),\ mLayer(layer)\ \{}
\DoxyCodeLine{00159\ \ \ \ \ \}}
\DoxyCodeLine{00160\ \ \ \ \ Segment\_25(const\ ::Point\_2\ \&p,\ const\ ::Point\_2\ \&q,\ \textcolor{keywordtype}{int}\ layer\ =\ 0)\ :\ mS2(p,\ q),\ mLayer(layer)\ \{}
\DoxyCodeLine{00161\ \ \ \ \ \}}
\DoxyCodeLine{00162\ \ \ \ \ \textcolor{keyword}{const}\ Segment\_2\&\ s2()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mS2;\ \}}
\DoxyCodeLine{00163\ \ \ \ \ \textcolor{keywordtype}{int}\ z()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mLayer;\ \}}
\DoxyCodeLine{00164\ \ \ \ \ \textcolor{keywordtype}{void}\ setLayer(\textcolor{keywordtype}{int}\ z)\ \{\ mLayer\ =\ z;\ \}}
\DoxyCodeLine{00165\ \ \ \ \ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ source()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}(mS2.source(),\ mLayer);\ \}}
\DoxyCodeLine{00166\ \ \ \ \ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ target()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}(mS2.target(),\ mLayer);\ \}}
\DoxyCodeLine{00167\ \ \ \ \ \textcolor{keyword}{const}\ Point\_2\&\ source\_2()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mS2.source();\ \}}
\DoxyCodeLine{00168\ \ \ \ \ \textcolor{keyword}{const}\ Point\_2\&\ target\_2()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mS2.target();\ \}}
\DoxyCodeLine{00169\ \ \ \ \ Real\ squared\_length()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mS2.squared\_length();\ \}}
\DoxyCodeLine{00170\ \ \ \ \ Real\ length()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ std::sqrt(squared\_length());\ \}}
\DoxyCodeLine{00171\ \ \ \ \ \textcolor{keywordtype}{bool}\ is\_horizontal()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mS2.is\_horizontal();\ \}}
\DoxyCodeLine{00172\ \ \ \ \ \textcolor{keywordtype}{bool}\ is\_vertical()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mS2.is\_vertical();\ \}}
\DoxyCodeLine{00173\ \ \ \ \ ::Vector\_2\ \mbox{\hyperlink{classSegment__25_a3d5d761f60090924f226decf6e1f6e96}{getDirection}}(Real\ s\ =\ 1.0)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00174\ \ \ \ \ ::Vector\_2\ getPerpendicularCCW(Real\ s\ =\ 1.0)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00175\ \ \ \ \ \textcolor{keywordtype}{int}\ angle45()\ \textcolor{keyword}{const};}
\DoxyCodeLine{00176\ \ \ \ \ Real\ anglePi2()\textcolor{keyword}{\ const\ }\{\ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ v\ =\ mS2.to\_vector();\ \textcolor{keywordflow}{return}\ std::atan(v.y()\ /\ v.x());\ \}}
\DoxyCodeLine{00177\ \ \ \ \ Segment\_25\&\ rectify(Real\ angleTolerance);}
\DoxyCodeLine{00178\ \ \ \ \ \textcolor{keywordtype}{int}\ majorAxis()\textcolor{keyword}{\ const\ }\{\ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ v\ =\ mS2.to\_vector();\ \textcolor{keywordflow}{return}\ std::abs(v.y())\ >\ std::abs(v.x())\ ?\ 1\ :\ 0;\ \}}
\DoxyCodeLine{00179\ \ \ \ \ Segment\_25\ opposite()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ Segment\_25(mS2.opposite(),\ z());\ \}}
\DoxyCodeLine{00180\ \ \ \ \ \textcolor{keywordtype}{bool}\ isXOrdered()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mS2.source().x()\ <=\ mS2.target().x();\ \}}
\DoxyCodeLine{00181\ \ \ \ \ \textcolor{keywordtype}{bool}\ isYOrdered()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mS2.source().y()\ <=\ mS2.target().y();\ \}}
\DoxyCodeLine{00182\ \ \ \ \ Segment\_25\ orderedX()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ isXOrdered()\ ?\ *this\ :\ opposite();\ \}}
\DoxyCodeLine{00183\ \ \ \ \ Segment\_25\ orderedY()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ isYOrdered()\ ?\ *this\ :\ opposite();\ \}}
\DoxyCodeLine{00184\ \ \ \ \ \textcolor{keywordtype}{bool}\ operator<(\textcolor{keyword}{const}\ Segment\_25\ \&s)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ (source()\ <\ s.source())\ ||\ (source()\ ==\ s.source()\ \&\&\ target()\ <\ s.target());\ \}}
\DoxyCodeLine{00185\ \ \ \ \ \textcolor{keywordtype}{bool}\ operator==(\textcolor{keyword}{const}\ Segment\_25\ \&s)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mLayer\ ==\ s.mLayer\ \&\&\ mS2\ ==\ s.mS2;\ \}}
\DoxyCodeLine{00186\ \ \ \ \ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{classSegment__25_a8da8576a8d1661ecf5b31dae10126607}{equals}}(\textcolor{keyword}{const}\ Segment\_25\ \&s)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00187\ \ \ \ \ Real\ maxNorm()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ std::max(std::abs(mS2.to\_vector().x()),\ std::abs(mS2.to\_vector().y()));\ \}}
\DoxyCodeLine{00188\ \ \ \ \ Real\ angleWith(\textcolor{keyword}{const}\ Segment\_25\&)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00189\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00190\ \ \ \ \ Segment\_2\ mS2;}
\DoxyCodeLine{00191\ \ \ \ \ \textcolor{keywordtype}{int}\ mLayer;}
\DoxyCodeLine{00192\ \};}
\DoxyCodeLine{00193\ }
\DoxyCodeLine{00197\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{int}\ \mbox{\hyperlink{classSegment__25_a8da8576a8d1661ecf5b31dae10126607}{Segment\_25::equals}}(\textcolor{keyword}{const}\ Segment\_25\ \&s)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00198\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00199\ \ \ \ \ \textcolor{keywordflow}{if}\ (mLayer\ !=\ s.mLayer)}
\DoxyCodeLine{00200\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00201\ \ \ \ \ \textcolor{keywordflow}{if}\ (mS2\ ==\ s.mS2)}
\DoxyCodeLine{00202\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 1;}
\DoxyCodeLine{00203\ \ \ \ \ \textcolor{keywordflow}{return}\ (mS2\ ==\ s.mS2.opposite())\ ?\ -\/1\ :\ 0;}
\DoxyCodeLine{00204\ \}}
\DoxyCodeLine{00208\ inline\ ::Vector\_2\ \mbox{\hyperlink{classSegment__25_a3d5d761f60090924f226decf6e1f6e96}{Segment\_25::getDirection}}(Real\ s)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00209\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00210\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ v\ =\ mS2.to\_vector();}
\DoxyCodeLine{00211\ \ \ \ \ \textcolor{keyword}{auto}\ s0\ =\ std::sqrt(v.squared\_length());}
\DoxyCodeLine{00212\ \ \ \ \ \textcolor{keywordflow}{return}\ v\ *\ (s\ /\ s0);}
\DoxyCodeLine{00213\ \}}
\DoxyCodeLine{00214\ inline\ ::Vector\_2\ Segment\_25::getPerpendicularCCW(Real\ s)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00215\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00216\ \ \ \ \ \textcolor{keyword}{auto}\ vd\ =\ \mbox{\hyperlink{classSegment__25_a3d5d761f60090924f226decf6e1f6e96}{getDirection}}(s);\ return\ ::Vector\_2(-\/vd.y(),\ vd.x());}
\DoxyCodeLine{00217\ \}}
\DoxyCodeLine{00218\ \textcolor{keyword}{inline}\ \mbox{\hyperlink{classSegment__25}{Segment\_25}}\&\ Segment\_25::rectify(Real\ angleTolerance)}
\DoxyCodeLine{00219\ \{}
\DoxyCodeLine{00220\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ v0\ =\ mS2.source();}
\DoxyCodeLine{00221\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ v1\ =\ mS2.target();}
\DoxyCodeLine{00222\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ A\ =\ std::abs(anglePi2());}
\DoxyCodeLine{00223\ \ \ \ \ \textcolor{keywordflow}{if}\ (std::abs(A)\ <\ angleTolerance)}
\DoxyCodeLine{00224\ \ \ \ \ \ \ \ \ mS2\ =\ Segment\_2(v0,\ Point\_2(v1.x(),\ v0.y()));}
\DoxyCodeLine{00225\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (std::abs(A\ -\/\ M\_PI\_2)\ <\ angleTolerance)}
\DoxyCodeLine{00226\ \ \ \ \ \ \ \ \ mS2\ =\ Segment\_2(v0,\ Point\_2(v0.x(),\ v1.y()));}
\DoxyCodeLine{00227\ \ \ \ \ \textcolor{keywordflow}{return}\ *\textcolor{keyword}{this};}
\DoxyCodeLine{00228\ \}}
\DoxyCodeLine{00229\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{int}\ Segment\_25::angle45()\textcolor{keyword}{\ const}}
\DoxyCodeLine{00230\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00231\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ dx\ =\ std::abs(source\_2().x()\ -\/\ target\_2().x());}
\DoxyCodeLine{00232\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ dy\ =\ std::abs(source\_2().y()\ -\/\ target\_2().y());}
\DoxyCodeLine{00233\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ t225\ =\ std::sqrt(2.0)\ -\/\ 1.0;}
\DoxyCodeLine{00234\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ t675\ =\ std::sqrt(2.0)\ +\ 1.0;}
\DoxyCodeLine{00235\ \ \ \ \ \textcolor{keywordflow}{if}\ (dy\ <\ t225\ *\ dx)}
\DoxyCodeLine{00236\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00237\ \ \ \ \ \textcolor{keywordflow}{if}\ (dy\ >\ t675\ *\ dx)}
\DoxyCodeLine{00238\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 90;}
\DoxyCodeLine{00239\ \ \ \ \ \textcolor{keywordflow}{return}\ 45;}
\DoxyCodeLine{00240\ \}}
\DoxyCodeLine{00241\ \textcolor{keyword}{inline}\ Real\ Segment\_25::angleWith(\textcolor{keyword}{const}\ \mbox{\hyperlink{classSegment__25}{Segment\_25}}\ \&s)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00242\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00243\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ u\ =\ s2().to\_vector();}
\DoxyCodeLine{00244\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ v\ =\ s.s2().to\_vector();}
\DoxyCodeLine{00245\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ d\ =\ u.x()\ *\ v.x()\ +\ u.y()\ *\ v.y();}
\DoxyCodeLine{00246\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ x\ =\ u.x()\ *\ v.y()\ -\/\ u.y()\ *\ v.x();}
\DoxyCodeLine{00247\ \ \ \ \ \textcolor{keywordflow}{return}\ std::atan2(x,\ d);}
\DoxyCodeLine{00248\ \}}
\DoxyCodeLine{00249\ }
\DoxyCodeLine{00250\ }
\DoxyCodeLine{00251\ \textcolor{comment}{//}}
\DoxyCodeLine{00252\ \textcolor{comment}{//\ Stream\ printing\ operators.}}
\DoxyCodeLine{00253\ \textcolor{comment}{//}}
\DoxyCodeLine{00254\ }
\DoxyCodeLine{00255\ \textcolor{keyword}{inline}\ std::ostream\&\ operator<<(std::ostream\ \&os,\ \textcolor{keyword}{const}\ Point\_2\ \&v)}
\DoxyCodeLine{00256\ \{}
\DoxyCodeLine{00257\ \ \ \ \ \textcolor{keywordflow}{return}\ os\ <<\ \textcolor{charliteral}{'('}\ <<\ v.x()\ <<\ \textcolor{charliteral}{','}\ <<\ v.y()\ <<\ \textcolor{charliteral}{')'};}
\DoxyCodeLine{00258\ \}}
\DoxyCodeLine{00259\ }
\DoxyCodeLine{00260\ \textcolor{keyword}{inline}\ std::ostream\&\ operator<<(std::ostream\ \&os,\ \textcolor{keyword}{const}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ \&v)}
\DoxyCodeLine{00261\ \{}
\DoxyCodeLine{00262\ \ \ \ \ \textcolor{keywordflow}{return}\ os\ <<\ \textcolor{charliteral}{'('}\ <<\ v.x()\ <<\ \textcolor{charliteral}{','}\ <<\ v.y()\ <<\ \textcolor{charliteral}{','}\ <<\ v.z()\ <<\ \textcolor{charliteral}{')'};}
\DoxyCodeLine{00263\ \}}
\DoxyCodeLine{00264\ }
\DoxyCodeLine{00265\ \textcolor{keyword}{inline}\ std::ostream\&\ operator<<(std::ostream\ \&os,\ \textcolor{keyword}{const}\ Vector\_2\ \&v)}
\DoxyCodeLine{00266\ \{}
\DoxyCodeLine{00267\ \ \ \ \ \textcolor{keywordflow}{return}\ os\ <<\ \textcolor{charliteral}{'('}\ <<\ v.x()\ <<\ \textcolor{charliteral}{','}\ <<\ v.y()\ <<\ \textcolor{charliteral}{')'};}
\DoxyCodeLine{00268\ \}}
\DoxyCodeLine{00269\ }
\DoxyCodeLine{00270\ \textcolor{keyword}{inline}\ std::ostream\&\ operator<<(std::ostream\ \&os,\ \textcolor{keyword}{const}\ Triangle\_2\ \&A)}
\DoxyCodeLine{00271\ \{}
\DoxyCodeLine{00272\ \ \ \ \ \textcolor{keywordflow}{return}\ os\ <<\ \textcolor{charliteral}{'<'}\ <<\ A.vertex(0)\ <<\ \textcolor{charliteral}{'\ '}\ <<\ A.vertex(1)\ <<\ \textcolor{charliteral}{'\ '}\ <<\ A.vertex(2)\ <<\ \textcolor{charliteral}{'>'};}
\DoxyCodeLine{00273\ \}}
\DoxyCodeLine{00274\ }
\DoxyCodeLine{00275\ \textcolor{keyword}{inline}\ std::ostream\&\ operator<<(std::ostream\ \&os,\ \textcolor{keyword}{const}\ Segment\_2\ \&s)}
\DoxyCodeLine{00276\ \{}
\DoxyCodeLine{00277\ \ \ \ \ \textcolor{keywordflow}{return}\ os\ <<\ \textcolor{charliteral}{'['}\ <<\ s.source()\ <<\ \textcolor{charliteral}{'\_'}\ <<\ s.target()\ <<\ \textcolor{charliteral}{']'};}
\DoxyCodeLine{00278\ \}}
\DoxyCodeLine{00279\ }
\DoxyCodeLine{00280\ \textcolor{keyword}{inline}\ std::ostream\&\ operator<<(std::ostream\ \&os,\ \textcolor{keyword}{const}\ \mbox{\hyperlink{classSegment__25}{Segment\_25}}\ \&s)}
\DoxyCodeLine{00281\ \{}
\DoxyCodeLine{00282\ \ \ \ \ \textcolor{keywordflow}{return}\ os\ <<\ \textcolor{charliteral}{'['}\ <<\ s.source()\ <<\ \textcolor{charliteral}{'\_'}\ <<\ s.target()\ <<\ \textcolor{stringliteral}{"{}|z="{}}\ <<\ s.z()\ <<\ \textcolor{charliteral}{']'};}
\DoxyCodeLine{00283\ \}}
\DoxyCodeLine{00284\ }
\DoxyCodeLine{00285\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ GYM\_PCB\_GEOMETRY\_H}}

\end{DoxyCode}
