UVa11178 - Morley's Theorem(向量旋转+直线交点)

题目链接


简介:三角形内角三等分线相交形成等边三角形


分析:

向量旋转和直线交点的练习


tip

新操作的第一次练习,板子不要写错

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>

using namespace std;

struct node{
	double x,y;
	node (double xx=0,double yy=0)
	{
		x=xx;y=yy;
	}
};

node operator + (const node &a,const node &b){return node(a.x+b.x,a.y+b.y);}
node operator - (const node &a,const node &b){return node(a.x-b.x,a.y-b.y);}
node operator * (const node &a,const double &b){return node(a.x*b,a.y*b);}
node operator / (const node &a,const double &b){return node(a.x/b,a.y/b);}

double Dot(node x,node y){return x.x*y.x+x.y*y.y;}
double Len(node x){return sqrt(Dot(x,x));}
double Angle(node x,node y){
	return acos( Dot(x,y)/Len(x)/Len(y) );
}

double Cross(node x,node y){return x.x*y.y-x.y*y.x;}

node rotate(node x,double a)
{
	return node(x.x*cos(a)-x.y*sin(a),x.x*sin(a)+x.y*cos(a));
}

node getpoint(node P,node v,node Q,node w)
{
	node u=P-Q;
	double t=Cross(w,u)/Cross(v,w);
	return P+v*t;
}

node get(node A,node B,node C)
{
	node X=C-B;
	double a=Angle(A-B,X);
	X=rotate(X,a/3);
	
	node Y=B-C;
	double b=Angle(A-C,Y);
    Y=rotate(Y,-b/3);      //负数表示顺时针转动 
    
    return getpoint(B,X,C,Y);
}

int main()
{
	node A,B,C,D,E,F;
	int T;
	scanf("%d",&T);
	while (T--)
	{
		scanf("%lf %lf",&A.x,&A.y);
		scanf("%lf %lf",&B.x,&B.y);
		scanf("%lf %lf",&C.x,&C.y);
		D=get(A,B,C);
		E=get(B,C,A);
		F=get(C,A,B);
		printf("%0.6lf %0.6lf %0.6lf %0.6lf %0.6lf %0.6lf\n",D.x,D.y,E.x,E.y,F.x,F.y);
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值