File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22#ifndef AFMT_FLAT_GEOMETRY
33#define AFMT_FLAT_GEOMETRY
44
5- #endif
5+ #include < cmath>
6+ #include < iostream>
7+
8+ template <class T >
9+ struct Vec {
10+ T x, y;
11+ Vec (T _x = 0 , T _y = 0 ) : x(_x), y(_y) {}
12+ inline T norm (void ) const { return x * x + y * y; }
13+ inline Vec operator *(T &&d) const { return Vec (x * d, y * d); }
14+ inline Vec operator /(T &&d) const { return Vec (x / d, y / d); }
15+ inline Vec operator +(Vec &&v) const { return Vec (x + v.x , y + v.y ); }
16+ inline Vec operator -(Vec &&v) const { return Vec (x - v.x , y - v.y ); }
17+ friend std::ostream &operator <<(std::ostream &out, Vec &&P) {
18+ return out << " (" << P.x << " , " << P.y << " )" ;
19+ }
20+ friend std::istream &operator >>(std::istream &in, Vec &P) {
21+ return in >> P.x >> P.y ;
22+ }
23+ };
24+
25+ template <class T >
26+ using Point = Vec<T>;
27+
28+ template <class T >
29+ inline T dot (Vec<T> &&a, Vec<T> &&b) {
30+ return a.x * b.x + a.y * b.y ;
31+ }
32+
33+ template <class T >
34+ inline T cross (Vec<T> &&a, Vec<T> &&b) {
35+ return a.x * b.y - a.y * b.x ;
36+ }
37+
38+ template <class T >
39+ struct Segment {
40+ };
41+
42+ #endif
You can’t perform that action at this time.
0 commit comments