POJ 1269 Intersecting Lines(简单计算几何,判断直线的关系)
来源:互联网 发布:windows录制视频 编辑:程序博客网 时间:2024/05/16 19:53
#include <iostream>#include <cstring>#include <cstdlib>#include <cstdio>#include <cmath>#include <vector>#include <queue>#include <stack>#include <map>#include <set>#define LL long long using namespace std;struct Point{double x, y;Point(double x = 0, double y = 0) : 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 - (Point A, Point 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-10;int dcmp(double x){if(fabs(x) < eps) return 0;else return x < 0 ? -1 : 1;}bool operator == (const Point& a, const Point& b){return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0;}double Cross(Vector A, Vector B) { return A.x * B.y - A.y * B.x; }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;}int main(){int T;scanf("%d", &T);printf("INTERSECTING LINES OUTPUT\n");while(T--){Point p1, p2, p3, p4;scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &p1.x, &p1.y, &p2.x, &p2.y, &p3.x, &p3.y, &p4.x, &p4.y);Vector A = p1 - p3; Vector B = p2 - p3;Vector C = p1 - p4; Vector D = p2 - p4;Vector F1 = p1 - p2; Vector F2 = p3 - p4;if(Cross(A, B) == 0 && Cross(C, D) == 0){printf("LINE\n");}else if(Cross(F1, F2) == 0){printf("NONE\n");}else{Point r = GetLineIntersection(p1, F1, p3, F2);printf("POINT %.2lf %.2lf\n", r.x, r.y);}}printf("END OF OUTPUT\n");return 0;}
0 0
- POJ 1269 Intersecting Lines(简单计算几何,判断直线的关系)
- POJ 1269 Intersecting Lines(简单判断直线关系)
- POJ 1269 Intersecting Lines(判断直线的位置关系)
- poj 1269 Intersecting Lines 【判断两条直线的关系】
- poj 1269 Intersecting Lines 判断直线的位置关系
- POJ 1269 Intersecting Lines(判断两直线关系)
- POJ 1269 Intersecting Lines 简单计算几何
- poj 1269 Intersecting Lines[直线的关系]
- POJ1269——Intersecting Lines(计算几何,直线关系判断)
- poj 1269 Intersecting Lines 计算几何 直线求交点
- poj 1269 Intersecting Lines(计算几何)
- POJ 1269 Intersecting Lines(计算几何)
- poj 1269 Intersecting Lines(计算几何)
- POJ 1269 Intersecting Lines(计算几何)
- POJ 1269 Intersecting Lines(直线相交的判断)
- POJ 1269 Intersecting Lines(判断两直线的位置关系)
- POJ 1269 Intersecting Lines(判断两条直线的位置关系)
- POJ 1269 Intersecting Lines(判断两条直线关系)
- 继承中的函数名称遮掩
- 高通平台android kernel 开机logo显示和传统linux一样
- php创建多级目录的函数
- 智能指针(smart pointer)
- 【Android】通过NDK编译libjpeg库
- POJ 1269 Intersecting Lines(简单计算几何,判断直线的关系)
- 习题3-7 DNA 序列
- 【BZOJ 1611】 [Usaco2008 Feb]Meteor Shower流星雨
- shell批量添加和删除前缀
- 柴餐讽篓匠毯剂噎骁板艽
- !POJ 1154--DFS(WA了20次)
- InnoDB 锁数管理据结构
- 规则 5.1 - 规则 5.3
- 欢迎使用CSDN-markdown编辑器