POJ1269(计算几何基础-直线与直线之间的关系与它们的交点)

fMRI数据处理:从DICOM到NIFTI(下) 上一篇我们完成了对原始DICOM的数据整理,将其整理为了BIDS目录结构。作为从从DICOM到NIFTI的最后一篇,当然是介绍如何批量将DICOM格式转NIFTI格式啦!从DICOM到NIFTI系列就完成啦!撒花★,°.°★。从核磁机器把数据拷回来——到整理成BIDS格式——到批量转格式;我们fMRI数据处理的第一步就算是正式迈出去啦!接下来的内容,敬请期待吧~ 阅读详情

Intersecting Lines
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 16216 Accepted: 7001
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

Mid-Atlantic 1996

题意:每次给你两条直线,问你这两条直线的关系是重合还是平行还是相交,如果是相交,则输出它们的交点。

解题思路:用向量的叉积来做就行,套一套模板。注意用g++交可能过不了,用c++交。

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
const double eps = 1e-9;
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 -(Vector A, Vector B) {return Vector(A.x - B.x, A.y - B.y);}//向量减
Vector operator *(Vector A, double p) {return Vector(p * A.x, p * A.y);}//向量的数乘
Vector operator /(Vector A, double p) {return Vector(A.x / p, A.y / p);}//向量的数除
Vector operator -(Vector A) {return Vector(-A.x, -A.y);}//向量的取反
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;
}
double Dot(Vector A, Vector B)//求解向量数量积
{
    return A.x * B.x + A.y * B.y;
}
double xmulti(Point p, Point a, Point b)//求向量pa叉乘pb
{
    return (a.x - p.x) * (b.y - p.y) - (a.y - p.y) * (b.x - p.x);
}
struct Line{
    Point p1;
    Point p2;
    Line(Point _p1, Point _p2){
        p1 = _p1;
        p2 = _p2;
    }
    Line(){
        p1 = Point(0, 0);
        p2 = Point(0, 0);
    }
};
typedef Line seg;
int line_loc(Line l1, Line l2)//判断直线的位置关系,1为平行,0为重合,-1为相交
{
    Point p1 = l1.p1;
    Point p2 = l1.p2;
    Point p3 = l2.p1;
    Point p4 = l2.p2;
    Vector v1 = p2 - p1;
    Vector v2 = p4 - p3;
    Vector v3 = p3 - p1;
    double d1 = Cross(v1, v2);
    double d2 = Cross(v1, v3);
    if(dcmp(d1) == 0 && dcmp(d2) == 0) return 0;//重合
    else if(dcmp(d1) == 0) return 1;
    else return -1;
}
Point seg_intersecting(Line l1, Line l2)//求两相交的直线(线段也一样)的交点
{
    Point A = l1.p1;
    Point B = l1.p2;
    Point C = l2.p1;
    Point D = l2.p2;
    double _x, _y;
    _x = (xmulti(A, B, D) * C.x - xmulti(A, B, C) * D.x) / (xmulti(A, B, D) - xmulti(A, B, C));
    _y = (xmulti(A, B, D) * C.y - xmulti(A, B, C) * D.y) / (xmulti(A, B, D) - xmulti(A, B, C));
    return Point(_x, _y);
}
int main()
{
    int T;
    scanf("%d", &T);
    Line L1, L2;
    cout<<"INTERSECTING LINES OUTPUT"<<endl;
    while(T--)
    {
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &L1.p1.x, &L1.p1.y, &L1.p2.x, &L1.p2.y, &L2.p1.x, &L2.p1.y, &L2.p2.x, &L2.p2.y);
        int ans = line_loc(L1, L2);
        if(ans == 0) cout<<"LINE"<<endl;
        else if(ans == 1) cout<<"NONE"<<endl;
        else
        {
            Point res = seg_intersecting(L1, L2);
            cout<<"POINT";
            printf(" %.2lf %.2lf\n", res.x, res.y);
        }
    }
    cout<<"END OF OUTPUT"<<endl;
    return 0;
}

复旦微实现串口在线升级BOOT.BIN 将该 demo 生成的 app(升级用)和 fsbl、最简化 bit 文件(可选)打包成 BOOT.BIN,作为 golden image 烧写在 qspi flash 偏移 0 地址开始的位置,其中最简化 bit 文件为在线升级功能提供必要的物理通道(如果不需要,可以不打包该文件),golden image 一旦发布基本不需要进行升级,由该 golden image 负责和上位机进行通信交互,完成业务 app、业务 bit 文件、uboot 以及操作系统 image 等文件在线升级,在qspi flash 阅读详情

相关推荐

极化码理论及算法研究4-巴氏参数、GA算法以及matlab仿真

目录 (如要找其他内容,欢迎访问我的主页寻找) #前言 #极化码概述 #极化码定义 #极化码编码 #极化码译码 #5G标准中极化码的编译码概述 #5G标准中极化码的编码 #5G标准中极化码的译码 #总结 极化码编码 ...

1万+

poj 1269Intersecting Lines (直线相交判断,求相交交点)

DescriptionWe 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)

退役的铜牌狗 328

PyWxDump实战:解密微信PC端本地数据库,实现聊天记录备份与分析

数据加密是保护敏感信息(如聊天记录)的核心技术,它通过特定算法将明文转换为密文,确保数据在存储和传输过程中的机密性。SQLCipher作为SQLite的加密扩展,采用AES-256算法对数据库文件进行页级加密,广泛应用于移动端和桌面端应用的数据保护。其技术价值在于,在保障用户隐私的前提下,为合规的数据备份、归档与分析提供了底层支持。在数据恢复、司法取证或合规审计等场景中,获取并解析此类加密数据是关键步骤。PyWxDump正是针对微信PC端本地SQLCipher加密数据库设计的工具,它通过逆向工程分析内存结构

461

poj 1263 Reflections (计算几何 反射)

题目意思:给出几个圆,再给出一个光源点和方向,模拟反射过程 解题思路: 1.求出射线; 2.求出在这条射线方向与圆的第一个交点,也就判断出是哪个圆; 3.把交点做为光源,求对称点,再反回步骤1。 难点在第二步,即要判断是否有两个交点(题目中已给出没有一个交点的情况) 还要判断这个交点是否是离光源最近的一点(不是刚反射过的那个圆),      还有要注意的是这是射线,不是直线,求出交点

三思 938

SpotBugs实战:10大类Bug检测规则详解与代码优化实例(附避坑清单)

本文深入解析SpotBugs在Java开发中的实战应用,详细讲解10大类Bug检测规则与代码优化实例,包括NPE防御、多线程安全、性能优化等关键问题。通过具体代码示例和避坑清单,帮助开发者提升代码质量,有效集成到CI/CD流程中。

weixin_42665255的博客 203

Type-C连接中的CC引脚:Rp与Rd电阻的识别与供电模式选择

本文深入解析Type-C接口中CC引脚的核心功能,包括Rp与Rd电阻的识别原理及供电模式选择机制。通过详细的分压计算和实战案例,揭示Type-C设备如何通过CC引脚实现方向检测、角色识别和供电协商,为硬件设计提供关键指导。

weixin_30616969的博客 348

1015 - 计算几何之直线与直线的关系 - Intersecting Lines(POJ1269)

传送门   题意 给你两条直线 若其相交则输出  交点的坐标 若其平行则输出  NONE 若其重合则输出  LINE   分析 比较基础的计算几何,就是考向量的使用 判断两条直线是否平行,就是看其叉积是否为0(可以这样理解,两个向量的叉积的集合意义就是平行四边形的面积,当你两条直线平行的时候,面积自然为0) 进一步如何判断是否重合呢?只需要在判断平行的基础上再看两条直线中是否...

Faithfully-xly的博客 276

别再只盯着Text-VQA了!这4个主流VQA数据集(含中英双语)的保姆级下载与对比指南

本文深入解析了Text-VQA、ST-VQA、OCR-VQA和EST-VQA这4个主流视觉问答数据集的特性与应用场景,提供了详细的下载与预处理指南。通过对比分析,帮助开发者根据项目需求选择最适合的数据集,避免因选型不当导致的模型性能问题,特别适合需要处理中英双语或多模态文本理解的AI项目。

weixin_42524708的博客 366

计算几何总结

计算几何其实,我都已经很久没有打过计算几何的题目了。。。现在也只记得一些皮毛了。。先Mark一下最基本的东西。 先定义点Point(x,y),向量Vector(x,y) 一条直线由一个初始点P1P_{1},以及其方向向量V1V_{1}组成。 接着我们重定义Vector的运算符。其中包含了向量加法,减法,数乘,点积,叉积(用^^表示) 这样子先定义了这些运算之后我们的算法可以变得非常好打。。 当然,其

PhilipsWeng的专栏 985

DASH 流媒体协议(Dynamic Adaptive Streaming over HTTP)概述——起源、MPD文件解析、相关项目

简单介绍DASH的起源与发展、MPD文件简要解析、相关项目,以及常见流媒体协议的比较

farewellyi的博客 6912

【全志V821_FoxPi】6-2 IMX219 MIPI摄像头适配

全志V821芯片适配IMX219 MIPI摄像头(2lane)教程,基于FoxPi开发板V1.2 SDK。文章详细介绍了IMX219的技术参数(800万像素、1/4英寸CMOS、支持1080P@30fps输出)及模组接口原理图。重点展示了设备树配置方法,包括PIO引脚定义(TWI0使用PA3/PA4,复位引脚PA2)、TWI0节点设置(100kHz时钟)以及VIND0节点中sensor0的完整配置(I2C地址0x20、MCLK0、RAW格式输出等)。配置过程强调需注意IMX219的器件地址转换(0x10→0

第四维度的博客 2263

poj 1269 Intersecting Lines(直线相交)

Intersecting Lines Time Limit:1000MS Memory Limit:10000K Total Submissions:8637 Accepted:3915 Description We all know that a pair of distinct points on a plane defi...

weixin_34293141的博客 250

《QT+PCL 第一章》:点云读取显示

点云读取显示一、核心代码二、QT设置三、效果展示 一、核心代码 二、QT设置 三、效果展示

阁楼 1万+

POJ 1269 Intersecting Lines(简单计算几何 · 直线与直线的位置关系)

一、传送门 http://poj.org/problem?id=1269 二、算法分析说明 三、代码 #include<cstdio> #include<cmath> #pragma warning(disable:4996) template<class _Ty> struct point { _Ty x, y; }; unsigned n; point&l...

COFACTOR 244

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

计算几何——直线交点poj1269

求直线交点还是要推一个公式的。。 见博客https://blog.csdn.net/u013050857/article/details/40923789 还要学一下向量的定点比分法 另外poj精度好像卡的厉害,zoj1280就没啥问题 #include<iostream> #include<cstring> #include<cstdio> ...

weixin_30384031的博客 117

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

【计算几何】【直线交点】Intersecting Lines

POJ 1269 至今不明白为什么POJ中把G++改成C++就对了 题目: 求两直线的关系,若相交求其交点 题解: #include<cstdio> #include<cmath> #include<string.h> #include<iostream> using namespace std; const int N=1e3+10; const ...

ygmjsjdboy的博客 252

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

【计算几何】POJ 1269 Intersecting Lines

POJ 1269 Intersecting Lines【传送门】 Intersecting Lines Time Limit:1000MS Memory Limit:10000K Total Submissions:20497 Accepted:8658 Description We all know that a pair of disti...

lesileqin的博客 221

POJ 1269 Intersecting Lines (两直线位置关系+求交点)

题意:给出两直线位置,求是平行、重合还是有交点,若有交点,输出。 题解:两直线位置关系+求交点 套板子。 #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<algorithm> #include<queue> #include<stack> #inclu

gongyuandaye的博客 236

Intersecting Lines POJ 1269(计算几何+判断直线间关系+求直线的交点)

Intersecting LinesPOJ - 1269 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 intersectio...

勉強しているユキさんです 596

POJ1269 简单的计算几何判断直线相交

Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8898   Accepted: 4003 Description We all know that a pair of distinct points on a plane defi

没错就是这样 745

ACM-计算几何之Intersecting Lines——poj1269

ACM 计算几何 Intersecting Lines poj1269

继续激情,继续奋斗。 2353

(计算几何)POJ1269Intersecting Lines

POJ1269Intersecting Lines 题意: 给你两条直线,相交输出交点,重合输出“LINE”,平行输出“NONE”。 思路: 直线相交的模板题,就是在平行和重合的时候可以用叉乘判断。 注意点: 提交G++的时候,不要用%.2lf,要用%.2f。 代码: #include<iostream> #include<stdio.h> #include<stdlib.h> #include<algorithm> #include<string.h&

Z7784562的博客 231

POJ-1269 直线相交的判断及交点

题意: 给了两个线段的两个端点的坐标。求他们相交的类型,如果正规相交并求出交点。 分析: 用点叉积,可以判断线段的相交类型(平行,共线,相交).大概是:  如果相交:设交点:p0(x0,y0),根据交点在两个线段上有方程:    (p1-p0)X(p2-p0)=0;    (p3-p0)X(p4-p0)=0; 展开就行了。 看代码就知道了: #include #include u

ZXLS-ZMR的专栏 853

POJ 1269 求两直线交点

题意:给出4个点,两个一组在两条直线上,求出这两条直线的重合部分,NONE就是平行,LINE就是重合,POINT就是有交点并且输出交点。 解析几何那么求,没什么好说的直接看代码吧。 #include #include #include using namespace std; typedef double PointType; struct point { PointType x,y

韩小侠的专栏 已迁移至lssea.com 622

【POJ】1269 Intersecting Lines(计算几何基础)

http://poj.org/problem?id=1269 我会说这种水题我手推公式+码代码用了1.5h? 还好新的一年里1A了~~~~ #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostrea...

77

Intersecting Lines (计算几何基础+判断两直线的位置关系)

题目链接: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...

di6499的博客 237
上一篇: POJ3304(计算几何基础-判断线段与直线相交)
下一篇: POJ3321(dfs序+树状数组)
creatorx
博客等级 码龄10年 127粉丝 145原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值