题目链接:https://vjudge.net/contest/276358#problem/D 题目大意:每一次给你两条直线,然后问你这两条直线的关系(平行,共线,相交(输出交点)). 具体思路:先判断共线,再去判断平行,其次是相交,这些都能通过叉积来判断. 首先输入的是四个点,P1,P2,P3,P4. 共线的话,我们线确定一条直线,P1,P2.然后我们看p1,p2,p3这三个点形成的两条线是不是为0,然后再去看p1,p2,p4形成的两条直线是不是也是0,如果都满足的话,就是共线. 平行的话,…
分析:有三种关系,共线,平行,还有相交,共线和平行都可以使用叉积来进行判断(其实和斜率一样),相交需要解方程....在纸上比划比划就出来了....   代码如下: ====================================================================================================================================== #include<math.h> #include<alg…
题目大意:给出两条直线,每个直线上的两点,求这两条直线的位置关系:共线,平行,或相交,相交输出交点. 题目思路:主要在于求交点 F0(X)=a0x+b0y+c0==0; F1(X)=a1x+b1y+c1==0; 设点(x0,y0)(x1,y1)过直线 解方程:a=y1-y0,b=x0-x1,c=x1y0-x0y1: 联立方程: X=(b0c1-b1c0)/d; Y=(a0c1-a1c0)/d; d=a0b1-a1b0; #include<iostream> #include<algori…
http://poj.org/problem?id=3304 给你几条线段  然后 让你找到一条直线让他在这条直线上的映射有一个重合点 如果有这条直线的话  这个重合的部分的两个端点一定是某两条线段的端点 所以只需要枚举每个点连成的直线能不能跟所有的线段相交就行了 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<ctype.h> #include<math.h> #…
Segments Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10921   Accepted: 3422 Description Given n segments in the two dimensional space, write a program, which determines if there exists a line such that after projecting these segments…
题目链接:http://poj.org/problem?id=1269 题面: 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) interse…
两条直线可能有三种关系:1.共线     2.平行(不包括共线)    3.相交. 那给定两条直线怎么判断他们的位置关系呢.还是用到向量的叉积 例题:POJ 1269 题意:这道题是给定四个点p1, p2, p3, p4,直线L1,L2分别穿过前两个和后两个点.来判断直线L1和L2的关系 这三种关系一个一个来看: 1. 共线. 如果两条直线共线的话,那么另外一条直线上的点一定在这一条直线上.所以p3在p1p2上,所以用get_direction(p1, p2, p3)来判断p3相对于p1p2的关…
题目链接:POJ 1269 Problem 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 becau…
题目传送门:POJ 1269 Intersecting Lines 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…
题目:POJ1269 题意:给你两条直线的坐标,判断两条直线是否共线.平行.相交,若相交,求出交点. 思路:直线相交判断.如果相交求交点. 首先先判断是否共线,之后判断是否平行,如果都不是就直接求交点了. #include <iostream> #include <string.h> #include <stdio.h> #include <algorithm> #include <math.h> #include <queue> #…