uva 11178二维几何(点与直线、点积叉积)
Problem D Morley’s Theorem Input: Standard Input
Output: Standard Output
Morley’s theorem states that that the lines trisecting the angles of an arbitrary plane triangle meet at the vertices of an equilateral triangle. For example in the figure below the tri-sectors of angles A, B and C has intersected and created an equilateral triangle DEF.
Of course the theorem has various generalizations, in particular if all of the tri-sectors are intersected one obtains four other equilateral triangles. But in the original theorem only tri-sectors nearest to BC are allowed to intersect to get point D, tri-sectors nearest to CA are allowed to intersect point E and tri-sectors nearest to AB are intersected to get point F. Trisector like BD and CE are not allowed to intersect. So ultimately we get only one equilateral triangle DEF. Now your task is to find the Cartesian coordinates of D, E and F given the coordinates of A, B, and C.
Input
First line of the input file contains an integer N (0<N<5001) which denotes the number of test cases to follow. Each of the next lines contain six integers . This six integers actually indicates that the Cartesian coordinates of point A, B and C are respectively. You can assume that the area of triangle ABC is not equal to zero, and the points A, B and C are in counter clockwise order.
Output
For each line of input you should produce one line of output. This line contains six floating point numbers separated by a single space. These six floating-point actually means that the Cartesian coordinates of D, E and F are respectively. Errors less than will be accepted.
Sample Input Output for Sample Input
2 1 1 2 2 1 2 0 0 100 0 50 50 |
1.316987 1.816987 1.183013 1.683013 1.366025 1.633975 56.698730 25.000000 43.301270 25.000000 50.000000 13.397460 |
题目大意:给一个三角形的三个顶点求1/3角平分线的交点。
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std; struct Point
{
double x,y;
Point(double x=,double y=):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.y*p);}
Vector operator /(Vector A,double p){return Vector(A.x/p,A.y/p);}
bool operator < (const Point &a,const Point &b)
{
return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
const double eps=1e-; int dcmp(double x)
{
if(fabs(x)<eps) return ;
else return x<?-:;
} bool operator == (const Point &a,const Point &b){
return (dcmp(a.x-b.x)== && dcmp(a.y-b.y)==);
} 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));} double Cross(Vector A,Vector B){ return A.x*B.y-A.y*B.x;}//叉积 Vector Rotate(Vector A,double rad)//向量旋转
{
return Vector(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
} Point GetLineIntersection(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 read_point()
{
Point A;
scanf("%lf %lf",&A.x,&A.y);
return A;
} Point getpoint(Point A,Point B,Point C)
{
Vector v1,v2;
double a1,a2;
v1=C-B;
v2=B-C;
a1=Angle(A-B,C-B)/;
a2=Angle(A-C,B-C)/;
v1=Rotate(v1,a1);
v2=Rotate(v2,-a2);
return GetLineIntersection(B,v1,C,v2);
} int main()
{
int T;
Point A,B,C,D,E,F;
scanf("%d",&T);
while(T--)
{
A=read_point();
B=read_point();
C=read_point();
D=getpoint(A,B,C);
E=getpoint(B,C,A);
F=getpoint(C,A,B);
printf("%.6lf %.6lf %.6lf %.6lf %.6lf %.6lf\n",D.x,D.y,E.x,E.y,F.x,F.y);
}
return ;
}
uva 11178二维几何(点与直线、点积叉积)的更多相关文章
- UVa 12304 (6个二维几何问题合集) 2D Geometry 110 in 1!
这个题能1A纯属运气,要是WA掉,可真不知道该怎么去调了. 题意: 这是完全独立的6个子问题.代码中是根据字符串的长度来区分问题编号的. 给出三角形三点坐标,求外接圆圆心和半径. 给出三角形三点坐标, ...
- UVA 11178 Morley's Theorem(旋转+直线交点)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18543 [思路] 旋转+直线交点 第一个计算几何题,照着书上代码打 ...
- Codeforces#514D(三分,简单二维几何)
#include<bits/stdc++.h>using namespace std;const double eps=1e-8;int n; struct node{ double ...
- Foj 2148 二维几何(点是否在三角形内)
题目大意:给n个坐标(不存在三点共线的点),求能够组成多少个凸四边形. #include<iostream> #include<cstdio> #include<cmat ...
- UVA 11019 二维匹配 AC自动机
这个题目要求在一个大矩阵里面匹配一个小矩阵,是AC自动机的灵活应用 思路是逐行按普通AC自动机匹配,用过counts[i][j]记录一下T字符矩阵以i行j列为开头的与P等大的矩阵区域 有多少行已经匹配 ...
- UVA 10465 Homer Simpson(全然背包: 二维目标条件)
UVA 10465 Homer Simpson(全然背包: 二维目标条件) http://uva.onlinejudge.org/index.php? option=com_onlinejudge&a ...
- UVA 10306 e-Coins(全然背包: 二维限制条件)
UVA 10306 e-Coins(全然背包: 二维限制条件) option=com_onlinejudge&Itemid=8&page=show_problem&proble ...
- UVA 11297 线段树套线段树(二维线段树)
题目大意: 就是在二维的空间内进行单个的修改,或者进行整块矩形区域的最大最小值查询 二维线段树树,要注意的是第一维上不是叶子形成的第二维线段树和叶子形成的第二维线段树要 不同的处理方式,非叶子形成的 ...
- UVA 11019 Matrix Matcher(二维hash + 尺取)题解
题意:在n*m方格中找有几个x*y矩阵. 思路:二维hash,总体思路和一维差不太多,先把每行hash,变成一维的数组,再对这个一维数组hash变成二维hash.之前还在想怎么快速把一个矩阵的hash ...
随机推荐
- codevs 2038 香甜的黄油 USACO
时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 农夫John发现做出全威斯康辛州最甜的黄油的方法:糖.把糖放在一片牧场上 ...
- 高精度A+B
#include<stdio.h> #include<string.h> int main() { int lenth1,lenth2,n,i,j,k,s; scanf(&qu ...
- FIBON高精度
#include<stdio.h> #include<string.h> int u,n; ],b[],h[]; ],y[],z[]; int main() { char s( ...
- Salt Master报错:Minion did not return. [No response]
在salt master端执行salt ‘*’ test.ping时,某一节点出现如下报错:Minion did not return. [No response] 登陆到这一节点查看minion的日 ...
- Codeforces Round #272 (Div. 2)-C. Dreamoon and Sums
http://codeforces.com/contest/476/problem/C C. Dreamoon and Sums time limit per test 1.5 seconds mem ...
- 解决IIS7多域名绑定同一物理目录,设置不同的默认文档的问题
IIS7多域名绑定同一物理目录,设置不同的默认文档是没办法设置的,因为在一个物理目录下只有一个web.config,并且IIS7把默认文档设置写在这里,导致所有域名的默认文档设置共享.解决方法:1.进 ...
- SniperOJ-leak-advanced-x86-64
借助DynELF实现无libc的漏洞利用小结 1.leak-advance与leak的区别在于一个可用函数是write,一个可用函数是puts.write比puts更容易利用,虽然write需要的参数 ...
- 一. python基础知识
第一章.变量与判断语句 1.第一个python程序 # -*- coding:utf-8 -*- # Author: Raymond print ("hello world") p ...
- __new__.py
def func(self): print('hello %s' %self.name)def __init__(self,name,age): self.name = name self.age = ...
- MariaDB数据库(五)
1. MariaDB主从架构 1.1 概述 主从架构用来预防数据丢失.主从多用于网站架构,因为主从的同步机制是异步的,数据的同步有一定延迟,也就是说有可能会造成数据的丢失,但是性能比较好,因此网站大多 ...