Morley's Theorem UVA - 11178
2017-07-24 15:53
239 查看
向量函数板
题意:给你一个三角形的三个点abc,求他们的三等分点的交点
题意:给你一个三角形的三个点abc,求他们的三等分点的交点
#include <iostream> #include <cstring> #include <algorithm> #include <cstdio> #include <cmath> #include <vector> using namespace std; const int N = 13; const int M= 1<<N; int st[M],ma[M]; int dp [M]; struct point { double x,y; point(double x=0,double y=0):x(x),y(y){} }; typedef point Vector; Vector operator +(point a,point b) { return Vector (a.x+b.x,a.y+b.y); } Vector operator *(point a,double b) { return Vector(a.x*b,a.y*b); } Vector operator -(point a,point b) { return Vector(a.x-b.x,a.y-b.y); } double dot(Vector a,Vector b)//点乘 { return a.x*b.x+a.y*b.y; } double cross(Vector a,Vector b)//叉乘 { return a.x*b.y-a.y*b.x; } double len (Vector a) { return sqrt(a.x*a.x+a.y*a.y); } Vector rotate1(Vector a,double rad)//逆时针旋转rad { return Vector(a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad)+a.y*cos(rad)); } point getans (point p,Vector v,point q,Vector w)//求两条直线的交点,唯一交点,当且仅当不共线 { Vector u=p-q; double t=cross(w,u)/cross(v,w); return p+v*t; } point getPoint(point a,point b,point c) { Vector bc=c-b; Vector ba=a-b; double rad=acos(dot(bc,ba)/len(bc)/len(ba)); Vector bd=rotate1(bc,rad/3); Vector cb=b-c; Vector ca=a-c; double rad1=acos(dot(cb,ca)/len(cb)/len(ca)); Vector cd=rotate1(cb,-rad1/3); return getans(b,bd,c,cd); } int main() { int T; scanf("%d",&T); while(T--) { point a,b,c; scanf("%lf %lf %lf %lf %lf %lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y); point d=getPoint(a,b,c);//后两个的 顺序不能写反了,因为有顺时针逆时针的方向问题 point e=getPoint(b,c,a); point f=getPoint(c,a,b); printf("%.6f %.6f ",d.x,d.y); printf("%.6f %.6f ",e.x,e.y); printf("%.6f %.6f\n",f.x,f.y); } return 0; }
相关文章推荐
- UVA 11178 Morley's Theorem
- Morley's Theorem UVA - 11178
- Morley's Theorem UVA - 11178
- Morley's Theorem UVA - 11178
- Morley's Theorem UVA - 11178
- Morley's Theorem UVA - 11178
- Morley's Theorem UVA - 11178
- Morley's Theorem UVA - 11178
- Morley's Theorem UVA - 11178
- UVA 11178 Morley's Theorem .
- uva 11178 Morley's Theorem 点线
- UVA 11178 Morley's Theorem——直线相交
- UVA - 11178-Morley’s Theorem
- Uva - 11178 - Morley's Theorem
- UVA - 11178 Morley's Theorem //几何初探
- uva11178 Morley's Theorem
- uva 11178 Morley's Theorem(计算几何-点和直线)
- UVA - 11178 - Morley's Theorem (计算几何~~)
- UVa 11178 Morley's Theorem (向量旋转)
- uva-11178 Morley's Theorem