-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecd4f50
commit e5a3a0c
Showing
7 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Author: me | ||
* Description: rad - deg converter. | ||
* Time: $O(1)$ | ||
*/ | ||
|
||
long double deg_to_rad(long double d) {return d*M_PI/180.0;} | ||
long double rad_to_deg(long double r) {return r*180.0/M_PI;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
\chapter{Geometry} | ||
|
||
\kactlimport{angle.cpp} | ||
\kactlimport{point.cpp} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Author: me | ||
* Description: Point and Vector. | ||
* Time: N/A | ||
*/ | ||
|
||
#define Vector Point /** keep-include */ | ||
|
||
template<class T> | ||
struct Point { | ||
// CAREFUL | ||
static constexpr T eps = 1e-9; | ||
|
||
T x, y; | ||
Point() {} | ||
Point(T _x, T _y) {x = _x; y = _y;} | ||
|
||
// Comparison | ||
bool operator<(Point p) const { | ||
if (abs(x - p.x) > eps) return x < p.x; | ||
return y < p.y; | ||
} | ||
|
||
bool operator==(Point p) const { | ||
return (abs(x-p.x) < eps) && (abs(y-p.y) < eps); | ||
} | ||
|
||
// Calculation | ||
T operator&(Vector v) const {return x*v.y - y*v.x;} | ||
T operator*(Vector v) const {return x*v.x + y*v.y;} | ||
Vector operator*(T d) const {return Vector(x*d, y*d);} | ||
Vector operator/(T d) const {return Vector(x/d, y/d);} | ||
Vector operator+(Vector v) const {return Vector(x+v.x,y+v.y);} | ||
Vector operator-(Vector v) const {return Vector(x-v.x,y-v.y);} | ||
|
||
void operator*=(T d) {x *= d; y *= d;} | ||
void operator/=(T d) {x /= d; y /= d;} | ||
void operator+=(Vector v) {x += v.x; y += v.y;} | ||
void operator-=(Vector v) {x -= v.x; y -= v.y;} | ||
|
||
T len2() {return x*x + y*y;} | ||
long double len() {return sqrt((long double)(len2()));} | ||
T dist2(Point p) {return (x-p.x)*(x-p.x) + (y-p.y)*(y-p.y);} | ||
long double dist(Point p) {return sqrt(dist2(p));} | ||
|
||
// Rotate to the left | ||
Point rotated(long double a) | ||
{return Point(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a));} | ||
void rotate(long double a) { | ||
T cx = x*cos(a) - y*sin(a); | ||
T cy = x*sin(a) + y*cos(a); | ||
x = cx; y = cy; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
\chapter{number-theory} | ||
\chapter{Number Theory} | ||
\kactlimport{modInverse.cpp} |
Binary file not shown.