#include#include#include#include#include#include#include#includeusingnamespacestd;typ" />

欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

【POJ】1269 Intersecting Lines(計算幾何基礎

系統 2168 0

http://poj.org/problem?id=1269

我會說這種水題我手推公式+碼代碼用了1.5h?

還好新的一年里1A了~~~~

      #include <cstdio>

#include <cstring>

#include <cmath>

#include <string>

#include <iostream>

#include <algorithm>

#include <queue>

#include <set>

#include <map>

using namespace std;

typedef long long ll;

#define pii pair<int, int>

#define mkpii make_pair<int, int>

#define pdi pair<double, int>

#define mkpdi make_pair<double, int>

#define pli pair<ll, int>

#define mkpli make_pair<ll, int>

#define rep(i, n) for(int i=0; i<(n); ++i)

#define for1(i,a,n) for(int i=(a);i<=(n);++i)

#define for2(i,a,n) for(int i=(a);i<(n);++i)

#define for3(i,a,n) for(int i=(a);i>=(n);--i)

#define for4(i,a,n) for(int i=(a);i>(n);--i)

#define CC(i,a) memset(i,a,sizeof(i))

#define read(a) a=getint()

#define print(a) printf("%d", a)

#define dbg(x) cout << (#x) << " = " << (x) << endl

#define error(x) (!(x)?puts("error"):0)

#define printarr2(a, b, c) for1(_, 1, b) { for1(__, 1, c) cout << a[_][__]; cout << endl; }

#define printarr1(a, b) for1(_, 1, b) cout << a[_] << '\t'; cout << endl

inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }

inline const int max(const int &a, const int &b) { return a>b?a:b; }

inline const int min(const int &a, const int &b) { return a<b?a:b; }



const double eps=1e-6;

struct Pt { double x, y; Pt(double _x=0, double _y=0) : x(_x), y(_y) {} };

int dcmp(double a) { if(abs(a)<eps) return 0; return a<0?-1:1; }

typedef Pt Vt;

Vt operator+ (const Pt &a, const Pt &b) { return Vt(a.x+b.x, a.y+b.y); }

Vt operator- (const Pt &a, const Pt &b) { return Vt(a.x-b.x, a.y-b.y); }

Vt operator* (const Pt &a, const double &b) { return Vt(a.x*b, a.y*b); }

bool operator== (const Pt &a, const Pt &b) { return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0; }

double Cross(Vt a, Vt b) { return a.x*b.y-b.x*a.y; }



struct Line {

	Pt p; Vt v;

	Line() {}

	Line(Pt &a, Pt &b) { p=a; v=b-a; }

};



Pt getLLP(Line &a, Line &b) {

	static Pt p, q;

	static Vt u, w, v;

	p=a.p; q=b.p;

	v=a.v; w=b.v;

	u=p-q;

	double t1=Cross(w, u)/Cross(v, w);

	return p+v*t1;

}

// -1:xiangjiao 0:chonghe 1:pingxing

int LineAndLine(Line &p, Line &q) {

	if(dcmp(Cross(p.v, q.v))!=0) return -1;

	return dcmp(Cross(q.p-p.p, q.v))==0 && dcmp(Cross(q.p-p.p, p.v))==0;

}

int main() {

	int n;

	while(~scanf("%d", &n)) {

		puts("INTERSECTING LINES OUTPUT");

		Line l[2]; Pt p[4];

		while(n--) {

			rep(k, 4) scanf("%lf%lf", &p[k].x, &p[k].y);

			l[0]=Line(p[0], p[1]);

			l[1]=Line(p[2], p[3]);

			int c=LineAndLine(l[0], l[1]);

			if(c==-1) { Pt pt=getLLP(l[0], l[1]); printf("POINT %.2f %.2f\n", pt.x, pt.y); }

			else if(c==0) puts("NONE");

			else puts("LINE");

		}

		puts("END OF OUTPUT");

	}

	return 0;

}


    

?


?

?

Description

We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) intersect in a line because they are on top of one another (i.e. they are the same line), 3) intersect in a point. In this problem you will use your algebraic knowledge to create a program that determines how and where two lines intersect.?
Your program will repeatedly read in four points that define two lines in the x-y plane and determine how and where the lines intersect. All numbers required by this problem will be reasonable, say between -1000 and 1000.?

Input

The first line contains an integer N between 1 and 10 describing how many pairs of lines are represented. The next N lines will each contain eight integers. These integers represent the coordinates of four points on the plane in the order x1y1x2y2x3y3x4y4. Thus each of these input lines represents two lines on the plane: the line through (x1,y1) and (x2,y2) and the line through (x3,y3) and (x4,y4). The point (x1,y1) is always distinct from (x2,y2). Likewise with (x3,y3) and (x4,y4).

Output

There should be N+2 lines of output. The first line of output should read INTERSECTING LINES OUTPUT. There will then be one line of output for each pair of planar lines represented by a line of input, describing how the lines intersect: none, line, or point. If the intersection is a point then your program should output the x and y coordinates of the point, correct to two decimal places. The final line of output should read "END OF OUTPUT".

Sample Input

            5

0 0 4 4 0 4 4 0

5 0 7 6 1 0 2 3

5 0 7 6 3 -6 4 -3

2 0 2 27 1 5 18 5

0 3 4 0 1 2 2 5


          

Sample Output

            INTERSECTING LINES OUTPUT

POINT 2.00 2.00

NONE

LINE

POINT 2.00 5.00

POINT 1.07 2.20

END OF OUTPUT


          

Source

【POJ】1269 Intersecting Lines(計算幾何基礎)


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 日韩在线不卡视频 | 性做久久久久免费看 | 二区三区偷拍浴室洗澡视频 | 中文字幕日韩欧美一区二区三区 | 久久日韩在线 | 亚洲一区二区三区免费在线观看 | 伊人狠狠干| 91视频网页版| 国产精品爱久久久久久久 | 久久久久久久免费视频 | 国产大片免费观看中文字幕 | 国产一级做a爰片在线 | 97av视频在线播放 | 亚洲欧洲精品一区二区三区 | 波多野结衣中文在线观看 | 日本在线免费观看视频 | 午夜性色一区二区三区不卡视频 | 国产真实乱freesex | 亚洲色图综合 | 国产午夜精品一区二区三区嫩草 | 精品久久综合一区二区 | 国产精品久久久久久久网站 | 久久久无码精品一区二区三区 | 日本黄大片视频在线播放 | 国产精品久久久久一区二区三区 | 日韩成人在线观看 | 日本一区二区三区精品国产 | 天天爱天天做天天干 | 欧美狠狠操 | 免费 视频 1级 | 国产一级一级毛片 | 日本黄色激情 | 国产成人精品免高潮在线观看 | 无遮挡又黄又刺激的视频 | 日本高清色视频www 99视频在线 | 欧美激情精品久久久久 | 色一欲一性一乱一区二区三区 | 91精品国产综合久久福利软件 | 一区二区三区在线 | 91免费在线看 | 亚洲午夜av |