POJ 1673 EXOCENTER OF A TRIANGLE(解三角形重心)
2024-09-03 06:16:45
题目链接:http://poj.org/problem?id=1673
AC代码:
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const double eps = 1e-;
const double pi = acos(-1.0);
int sgn(double x)
{
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
struct Point{
double x, y;
Point(){}
Point(double _x, double _y){
x = _x, y = _y;
}
bool operator == (Point b) const{
return sgn(x - b.x) == && sgn(y - b.y) == ;
}
bool operator < (Point b)const{
return sgn(x - b.x) == ? sgn(y - b.y < ) : x < b.x;
}
Point operator - (const Point &b)const{
return Point(x - b.x, y - b.y);
}
//²æ»ý
double operator ^(const Point &b){
return x * b.y - y * b.x;
}
//µã»ý
double operator *(const Point &b){
return x * b.x + y * b.y;
}
double len(){
return hypot(x, y);
}
double len2(){
return x * x + y * y;
}
double distant(Point p){
return hypot(x - p.x, y - p.y);
}
Point operator + (const Point &b)const{
return Point (x + b.x, y + b.y);
}
Point operator * (const double &k)const{
return Point(x * k, y * k);
}
Point operator / (const double &k)const{
return Point(x / k, y / k);
}
Point rotate(Point p, double angle){
Point v = (*this) - p;
double c = cos(angle), s = sin(angle);
return Point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);
}
};
Point GetLineIntersection(Point P, Point v, Point Q, Point w){
Point u = P - Q;
double t =(w^u)/(v^w);
return P + v*t;
}
int main()
{
Point A, B, C;
int n;
scanf("%d",&n);
while(n--)
{
scanf("%lf %lf %lf %lf %lf %lf",&A.x, &A.y, &B.x, &B.y, &C.x, &C.y);
Point v = B,u = C;
v = v.rotate(A, pi / 2.0), u = u.rotate(B, pi / 2.0);
Point c = GetLineIntersection(C, v - A, A, u - B);
printf("%.4f %.4f\n",c.x + eps, c.y + eps);
}
return ;
}
最新文章
- UML类图(上):类、继承和实现
- centos7 编译php56
- T138
- 从全局中通过class类名获取标签
- Python快速建站系列-Part.Five.1-个人主页及发表文章
- XCode打包脚本
- Ibatis中传List参数
- 多校5 HDU5787 K-wolf Number 数位DP
- UVA 315 315 - Network(求割点个数)
- 第一个php网页
- ORACLE模拟临时文件、日志成员、口令文件丢失情况与恢复【weber出品】
- bat脚本命令
- js面试题-2
- android 高仿京东
- 【Netty】(4)—源码AbstractBootstrap
- prometheus + grafana + node_exporter + alertmanager 的安装部署与邮件报警 (一)
- warmpserver 配置别人能访问自己的项目地址
- Eclipse 中构建 Maven 项目的完整过程 - 动态 Web 项目
- C# 数据推送 实时数据推送 轻量级消息订阅发布 多级消息推送 分布式推送
- unittest常用的断言方法
热门文章
- pandas中的quantile函数
- Tika教程
- SpringBoot2.0拦截器 与 1.X版本拦截器 的实现
- poi 处理空单元格
- spark优化——依赖包传入HDFS_spark.yarn.jar和spark.yarn.archive的使用
- 微信公众号开发笔记-验证token
- P4363 [九省联考2018]一双木棋
- python调用tushare获取沪深股通十大成交股
- Permission denied
- window 下搭建流媒体服务器ffmpeg nginx-rmtp-module