计算几何板子
Posted kcn999
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了计算几何板子相关的知识,希望对你有一定的参考价值。
基础
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-8;
int cmp(double a, double b)
{
if (a - b > eps) return 1;
if (a - b < -eps) return -1;
return 0;
}
struct Vector
{
double x, y;
Vector(double x = 0, double y = 0) : x(x), y(y) {}
friend Vector operator + (Vector a, Vector b) {return Vector(a.x + b.x, a.y + b.y);}
friend Vector operator - (Vector a, Vector b) {return Vector(a.x - b.x, a.y - b.y);}
friend Vector operator * (Vector a, double k) {return Vector(a.x * k, a.y * k);}
friend Vector operator / (Vector a, double k) {return Vector(a.x / k, a.y / k);}
friend bool operator < (Vector a, Vector b) {return cmp(a.x, b.x) ? cmp(a.x, b.x) == -1 : cmp(a.y, b.y) == -1;}
friend bool operator == (Vector a, Vector b) {return cmp(a.x, b.x) == 0 && cmp(a.y, b.y) == 0;}
friend double operator * (Vector a, Vector b) {return a.x * b.x + a.y * b.y;}
friend double operator ^ (Vector a, Vector b) {return a.x * b.y - a.y * b.x;}
double Length() {return sqrt(x * x + y * y);}
};
typedef Vector Point;
double Angle(Vector a, Vector b) {return acos(a * b / a.Length() / b.Length());}
int main()
{
return 0;
}
以上是关于计算几何板子的主要内容,如果未能解决你的问题,请参考以下文章