hxy的未完成的计算几何模板

  1 #include <iostream>
  2 #include <cstring>
  3 #include <cstdio>
  4 #include <cmath>
  5 using namespace std;
  6
  7 const double PI = acos(-1);
  8 const double eps = 1e-8;
  9
 10 int sgn( double x )
 11 {
 12     if ( fabs(x) < eps ) return 0;
 13     return x > 0 ? x : -x;
 14 }
 15
 16 struct Point
 17 {
 18     double x, y;
 19
 20     Point(){}
 21
 22     Point( double _x, double _y )
 23     {
 24         x = _x, y = _y;
 25     }
 26
 27     Point operator + ( const Point & o ) const
 28     {
 29         return Point( x + o.x, y + o.y );
 30     }
 31
 32     Point operator - ( const Point & o ) const
 33     {
 34         return Point( x - o.x, y - o.y );
 35     }
 36
 37     Point operator * ( double p )
 38     {
 39         return Point( x * p, y * p );
 40     }
 41
 42     Point operator / ( double p )
 43     {
 44         return Point( x / p, y / p );
 45     }
 46
 47     bool operator == ( const Point & o ) const
 48     {
 49         return sgn( x - o.x ) == 0 && sgn( y - o.y ) == 0;
 50     }
 51
 52 };
 53
 54 typedef Point Vector;
 55
 56 double dot( Vector a, Vector b )
 57 {
 58     return a.x * b.x + a.y * b.y;
 59 }
 60
 61 double length( Vector a )
 62 {
 63     return sqrt( dot( a, a ) );
 64 }
 65
 66 double angle( Vector a, Vector b )
 67 {
 68     return acos( dot( a, b ) / length(a) / length(b) );
 69 }
 70
 71 double cross( Vector a, Vector b )
 72 {
 73     return a.x * b.y - a.y * b.x;
 74 }
 75
 76 double darea2( Point a, Point b, Point c )
 77 {
 78     return cross( b - a, c - a );
 79 }
 80
 81 double area( Point a, Point b, Point c )
 82 {
 83     return fabs( cross( b - a, c - a ) * 0.5 );
 84 }
 85
 86 Vector rotate( Vector a, double rad )
 87 {
 88     return Vector( a.x * cos(rad) - a.y * sin(rad),
 89                    a.x * sin(rad) + a.y * cos(rad) );
 90 }
 91
 92 double polygonArea( Point * p, int n )
 93 {
 94     double area = 0;
 95     for ( int i = 1; i < n - 1; i++ )
 96     {
 97         area += cross( p[i] - p[0], p[i + 1] - p[0] );
 98     }
 99     return fabs( area * 0.5 );
100 }
101
102 struct Circle
103 {
104     Point c;
105     double r;
106 };
107
108 double angle( Vector v )
109 {
110     return atan2( v.y, v.x );
111 }
112
113 int main ()
114 {
115
116
117     return 0;
118 }
时间: 2024-07-30 02:08:35

hxy的未完成的计算几何模板的相关文章

【模板整合】【及时更新】【天坑】计算几何模板

计算几何模板要写的内容真多- 我写烦了-先写这些放上来吧- #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #define MAXDBL 1e20 #define eps 1e-9 #define pi acos(-1) using namespace std; stru

【转】计算几何模板

[转载注明出处 @AOQNRMGYXLMV ] #include <cstdio> #include <algorithm> #include <cmath> #include <vector> using namespace std; //lrj计算几何模板 struct Point { double x, y; Point(double x=0, double y=0) :x(x),y(y) {} }; typedef Point Vector; Poi

lrj计算几何模板

整理了一下大白书上的计算几何模板. 1 #include <cstdio> 2 #include <algorithm> 3 #include <cmath> 4 using namespace std; 5 //lrj计算几何模板 6 struct Point 7 { 8 double x, y; 9 Point(double x=0, double y=0) :x(x),y(y) {} 10 }; 11 typedef Point Vector; 12 const

计算几何模板(刘汝佳本)(转载)

转载自: 计算几何模板(仿照刘汝佳大白书风格) 想想自己一个学期连紫皮都没看完就想自杀 // Geometry.cpp #include <bits/stdc++.h> #define LL long long #define lson l, m, rt<<1 #define rson m+1, r, rt<<1|1 #define PI 3.1415926535897932384626 #define EXIT exit(0); #define DEBUG puts(

计算几何模板

是时候贴一些几何模板了.. #include<iostream> #include<cstring> #include<cstdio> #include<string> #include<algorithm> #include<queue> #include<cmath> #include<vector> using namespace std; #define mnx 50050 #define LL lon

ZBT的计算几何模板

Basic template 一个基础型模板包括一个向量的实现 DATE: 2015-06-01 #define op operator #define __ while #define _0 return typedef long long ll; inline ll _(ll a,ll b){ll t;__(a){t=a;a=b%a;b=t;}_0 b;} struct frac{ ll u,d; frac(ll u=0,ll d=1):u(u),d(d){} frac op()(){ll

hdu 3060 Area2 (计算几何模板)

Problem Description 小白最近又被空军特招为飞行员,参与一项实战演习.演习的内容还是轰炸某个岛屿(这次的岛屿很大,很大很大很大,大到炸弹怎么扔都能完全在岛屿上引爆),看来小白确实是飞行员的命...这一次,小白扔的炸弹比较奇怪,爆炸的覆盖区域不是圆形,而是一个不规则的简单多边形,请你再次帮助小白,计算出炸到了多少面积.需要注意的是,这次小白一共扔了两枚炸弹,但是两枚炸弹炸到的公共部分的面积只能计算一次. Input 首先输入两个数n,m,分别代表两枚炸弹爆炸覆盖到的图形的顶点数:

LA 3263 好看的一笔画 欧拉几何+计算几何模板

题意:训练指南260 #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <cmath> using namespace std; struct Point { double x, y; Point(double x = 0, double y = 0) : x(x) , y(y) { } }; typedef Point V

计算几何模板 (bzoj 1336,poj 2451 ,poj3968)

poj 3968 (bzoj 2642) 二分+半平面交,每次不用排序,这是几个算几版综合. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<vector> #include<deque> using namespace std; #define MAXN 100000 na