zoukankan      html  css  js  c++  java
  • 计算几何 《模板》

    #include<iostream>
    #include<cstdio>
    #include<string>
    #include<algorithm>
    # include<cmath>
    using namespace std;
    struct point
    {
        double x,y;
        point(double x=0,double y=0):x(x),y(y) {}
    };
    
    typedef point Vector;
    
    Vector operator +(Vector A,Vector B)
    {
        return  Vector(A.x+B.x,A.y+B.y);
    }
    
    Vector operator -(Vector A,Vector B)
    {
        return Vector(A.x-B.x,A.y-B.y);
    }
    
    Vector operator *(Vector A,double p)
    {
        return Vector(A.x*p, A.x*p);
    }
    
    Vector operator /(Vector A,double p)
    {
        return Vector(A.x/p, A.x/p);
    }
    
    const int esp=1e-10;
    
    bool operator <(const point& a,const point& b)
    {
        return a.x<b.x||(a.x==b.x && a.y<b.y);
    }
    
    int dcmp(double x)
    {
        if(fabs(x)<esp) return 0;
        else
            return x<0?

    -1:1; } bool operator ==(const point& a,const point& b) { return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0; } double Dot(Vector A, Vector B) { return A.x*B.x+A.y*B.y; } double Length(Vector A) { return sqrt(Dot(A,A)); } double Angle(Vector A, Vector B) { return acos(Dot(A,B))/Length(A)/Length(B); } Vector Rotate (Vector A,double rad) { return Vector(A.x*cos(rad)-A.y*sin(rad), A.x*sin(rad)+A.y*cos(rad)); } double cross(Vector A, Vector B) { return A.x*B.y-A.y*B.x; } double Area2(point A, point B, point C) { return cross(B-A, C-A); } int main() { return 0; }


  • 相关阅读:
    PHP小案例
    PHP函数
    PHP基础语法
    PHP基础知识
    tp5.1前台模板的系统变量输出
    PHP常用方法很有意义的博客网址
    VS 2010(2005)Unicode使用cximage库Load函数问题
    坑爹的CFile::Remove
    固定CDockablePane的一些小技巧
    (转)理解Bitblt、StretchBlt与SetDIBitsToDevice、StretchDibits
  • 原文地址:https://www.cnblogs.com/wgwyanfs/p/6767355.html
Copyright © 2011-2022 走看看