/**
* Author: Victor Lecomte, chilli
* Date: 2019-05-05
* License: CC0
* Source: https://vlecomte.github.io/cp-geo.pdf
* Description:\\
\begin{minipage}{75mm}
If a unique intersection point of the lines going through s1,e1 and s2,e2 exists \{1, point\} is returned.
If no intersection point exists \{0, (0,0)\} is returned and if infinitely many exists \{-1, (0,0)\} is returned.
The wrong position will be returned if P is Point<ll> and the intersection point does not have integer coordinates.
Products of three coordinates are used in intermediate steps so watch out for overflow if using int or ll.
\end{minipage}
\begin{minipage}{15mm}
\includegraphics[width=\textwidth]{src/geometry/lineIntersection}
\end{minipage}
* Usage:
* auto res = lineInter(s1,e1,s2,e2);
* if (res.first == 1)
* cout << "intersection point at " << res.second << endl;
* Status: stress-tested, and tested through half-plane tests
*/#pragma once
#include"src/geometry/Point.h"template<classP>pair<int,P>lineInter(Ps1,Pe1,Ps2,Pe2){autod=(e1-s1).cross(e2-s2);if(d==0)// if parallelreturn{-(s1.cross(e1,s2)==0),P(0,0)};autop=s2.cross(e1,e2),q=s2.cross(e2,s1);return{1,(s1*p+e1*q)/d};}
Traceback(mostrecentcalllast):File"/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/onlinejudge_verify/documentation/build.py",line71,in_render_source_code_statbundled_code=language.bundle(stat.path,basedir=basedir,options={'include_paths':[basedir]}).decode()~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/onlinejudge_verify/languages/cplusplus.py",line187,inbundlebundler.update(path)~~~~~~~~~~~~~~^^^^^^File"/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py",line312,inupdateraiseBundleErrorAt(path,i+1,"#pragma once found in a non-first line")onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt:src/geometry/lineIntersection.h:line22:#pragmaoncefoundinanon-firstline