依旧是叉积的应用 判定重合:也就是判断给定的点是否共线的问题——叉积为0 if(!cross(p1,p2,p3) && !cross(p1,p2,p4))printf("LINE\n"); 因为给的是整数所以用非号来判断 平行也好说,就用高中知识就行了 else if((x1 - x2) * (y3 - y4) == (y1 - y2) * (x3 - x4))printf("NONE\n"); 接下来就是求交点了,设焦点为x,那么p1,p2,x共线…
Line.h #pragma once //Microsoft Visual Studio 2015 Enterprise //根据两点式方法求直线,并求两条直线的交点 #include"BoundaryPoint.h" #include"Coordinates.h" class Line { public: Line GetLine(BoundaryPoint sourcePoint, BoundaryPoint endPoint); Line GetLine(C…
题目:POJ1269 题意:给你两条直线的坐标,判断两条直线是否共线.平行.相交,若相交,求出交点. 思路:直线相交判断.如果相交求交点. 首先先判断是否共线,之后判断是否平行,如果都不是就直接求交点了. #include <iostream> #include <string.h> #include <stdio.h> #include <algorithm> #include <math.h> #include <queue> #…
http://poj.org/problem?id=1269 我今天才知道原来标准的浮点输出用%.2f   并不是%.2lf  所以wa了好几次 题目大意:   就给你两个线段 然后求这两个线段所在的直线的关系  有共线  平行  和相交 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> #include<math.h> #define N 200…
分析:有三种关系,共线,平行,还有相交,共线和平行都可以使用叉积来进行判断(其实和斜率一样),相交需要解方程....在纸上比划比划就出来了....   代码如下: ====================================================================================================================================== #include<math.h> #include<alg…
,); ,); ,); ,); var p:Point = new Point(); trace(checkPoint()) function checkPoint() { if (p1Start.x == p1End.x) { if (p2Start.x == p2End.x) { trace("平行线"); p = null; } else { p.x = p1Start.x; p.y = p2Start.y+(p1Start.x-p2Start.x)/(p2End.x-p2Sta…
//粘贴到帧上运行即可 var p1Start:Point = new Point(0,0); var p1End:Point = new Point(50,50); var p2Start:Point = new Point(50,50); var p2End:Point = new Point(100,100); var p:Point = new Point(); trace(checkPoint()) function checkPoint() { if (p1Start.x == p1…
题目链接:http://poj.org/problem?id=1269 题意:给你两条直线上的任意不同的两点,然后求两条直线的位置关系,如果相交于一点输出该点坐标; #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<stdio.h> #include<map> #include<vector> #inclu…
#include <iostream> #include <cmath> #include <vector> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <algorithm> using namespace std; #define MAX_N 110 /*------------------常量区----------------…
算法提高 两条直线   时间限制:1.0s   内存限制:256.0MB        问题描述 给定平面上n个点. 求两条直线,这两条直线互相垂直,而且它们与x轴的夹角为45度,并且n个点中离这两条直线的曼哈顿距离的最大值最小. 两点之间的曼哈顿距离定义为横坐标的差的绝对值与纵坐标的差的绝对值之和,一个点到两条直线的曼哈顿距离是指该点到两条直线上的所有点的曼哈顿距离中的最小值. 输入格式 第一行包含一个数n. 接下来n行,每行包含两个整数,表示n个点的坐标(横纵坐标的绝对值小于109). 输出…