zoukankan      html  css  js  c++  java
  • uva 11178

    题意:根据A,B,C三点的位置确定D,E,F三个点的位置。

    贴模板

      1 #include<cstdio>
      2 #include<cmath>
      3 #include<cstring>
      4 #include<algorithm>
      5 #include<iostream>
      6 #include<memory.h>
      7 #include<cstdlib>
      8 #include<vector>
      9 #define clc(a,b) memset(a,b,sizeof(a))
     10 #define LL long long int
     11 using namespace std;
     12 const int N=100010;
     13 const int inf=0x3f3f3f3f;
     14 const double eps = 1e-10;
     15 
     16 struct Point
     17 {
     18     double x, y;
     19     Point(double x = 0, double y = 0) : x(x), y(y) { }
     20 };
     21 
     22 typedef Point Vector;
     23 
     24 Vector operator + (Vector A, Vector B)
     25 {
     26     return Vector(A.x + B.x, A.y + B.y);
     27 }
     28 
     29 Vector operator - (Point A, Point B)
     30 {
     31     return Vector(A.x - B.x, A.y - B.y);
     32 }
     33 
     34 Vector operator * (Vector A, double p)
     35 {
     36     return Vector(A.x * p, A.y * p);
     37 }
     38 
     39 Vector operator / (Vector A, double p)
     40 {
     41     return Vector(A.x / p, A.y / p);
     42 }
     43 
     44 bool operator < (const Point& a, const Point& b)
     45 {
     46     return a.x < b.x || (a.x == b.x && a.y < b.y);
     47 }
     48 
     49 int dcmp(double x)
     50 {
     51     if(fabs(x) < eps) return 0;
     52     return x < 0 ? -1 : 1;
     53 }
     54 
     55 bool operator == (const Point& a, const Point& b)
     56 {
     57     return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0;
     58 }
     59 
     60 double Dot(Vector A, Vector B)//点乘
     61 {
     62     return A.x * B.x + A.y * B.y;    
     63 }
     64 
     65 double Length(Vector A) //向量的模
     66 {
     67     return sqrt(Dot(A, A));   
     68 }
     69 
     70 double Angle(Vector A, Vector B)//两个向量的夹角
     71 {
     72     return acos(Dot(A, B) / Length(A) / Length(B));    
     73 }
     74 
     75 double Cross(Vector A, Vector B)//叉乘
     76 {
     77     return A.x * B.y - A.y * B.x;    
     78 }
     79 
     80 double Area(Point A, Point B, Point C)//三个点组成的三角形的面积
     81 {
     82     return Cross(B - A, C - A);    
     83 }
     84 
     85 Vector Rotate(Vector A, double rad)   //向量A逆时针旋转rad弧度后的坐标
     86 {
     87     return Vector(A.x * cos(rad) - A.y * sin(rad), A.x * sin(rad) + A.y * cos(rad));
     88 }
     89 
     90 
     91 Point GetLineIntersection(Point P, Vector v, Point Q, Vector w)//求直线交点
     92 {
     93     Vector u = P - Q;
     94     double t = Cross(w, u) / Cross(v, w);
     95     return P + v * t;
     96 }
     97 
     98 Point getD(Point A, Point B, Point C)
     99 {
    100     Vector v1 = C - B;
    101     double a1 = Angle(A-B, v1);
    102     v1 = Rotate(v1, a1/3);
    103 
    104     Vector v2 = B - C;
    105     double a2 = Angle(A-C, v2);
    106     v2 = Rotate(v2, -a2/3);
    107 
    108     return GetLineIntersection(B, v1, C, v2);
    109 }
    110 int main()
    111 {
    112     int T;
    113     Point A, B, C, D, E, F;
    114     scanf("%d",&T);
    115     while(T--)
    116     {
    117         scanf("%lf%lf%lf%lf%lf%lf",&A.x, &A.y, &B.x, &B.y, &C.x, &C.y);
    118         D = getD(A, B, C);
    119         E = getD(B, C, A);
    120         F = getD(C, A, B);
    121         printf("%lf %lf %lf %lf %lf %lf
    ", D.x, D.y, E.x, E.y, F.x, F.y);
    122     }
    123     return 0;
    124 }
    View Code
  • 相关阅读:
    C++ 共用体
    C++ 作用域内枚举
    C++ 作用域为类的常量
    C++ 类作用域
    C++ 对象数组
    C++ this指针
    C++ const成员函数
    C++ 对象的初始化和赋值
    C++ 析构函数
    乌班图 之 apt命令 及 VMware共享文件夹
  • 原文地址:https://www.cnblogs.com/ITUPC/p/4868461.html
Copyright © 2011-2022 走看看