POJ 1269 Intersecting Lines

双目立体成像(一)双目图片生成点云 利用左右目图片生成点云 阅读详情
Intersecting Lines
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 6233 Accepted: 2939

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


求俩直线关系的,相交,平行,或重合。

基础的计算几何~一点点建立起计算几何的自信~

推了下求交点的公式

首先看图


两直线AB,CD相交于O点

设q = 向量AC与向量DC的叉积 = AG * CD

    p = 向量AB与向量DC的叉积 = (AG + BH) * CD

得AG / (AG + BH) = q / p

因为BHO和AGO是相似三角形,所以

得 AO / AB = AO / (AO + OB) = AG / (AG + BH) = q / p

于是AO = AB * q / p

即O.x - A.x = (B.x - A.x) * q / p

    O.y - A.y = (B.y - A.y) * q / p


剩下的

两直线重合:

C,D点一定在AB上,所以,(X表示叉积)

CB X AB = DB X AB = 0

两直线平行:

AB X CD = 0

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const double eps = 0.000001;

struct LPoint{
	double x, y;
};
struct LLine{
	LPoint bg, ed;
};

int dblcmp(double a, double b){
	if (a - b > eps) return 1;
	if (b - a > eps) return -1;
	return 0;
}

double VecPro(double a, double b, double p, double q){
	return (a * q) - (b * p);
}

int main(){
	int n;
	double p, q, t;
	LLine a, b;
	LPoint o;
	scanf("%d", &n);
	printf("INTERSECTING LINES OUTPUT\n");
	while(n--){
		scanf("%lf%lf%lf%lf", &a.bg.x, &a.bg.y, &a.ed.x, &a.ed.y);
		scanf("%lf%lf%lf%lf", &b.bg.x, &b.bg.y, &b.ed.x, &b.ed.y);
		p = VecPro(a.bg.x - a.ed.x, a.bg.y - a.ed.y, b.bg.x - a.ed.x, b.bg.y - a.ed.y);
		q = VecPro(a.bg.x - a.ed.x, a.bg.y - a.ed.y, b.ed.x - a.ed.x, b.ed.y - a.ed.y);
		t = VecPro(a.bg.x - a.ed.x, a.bg.y - a.ed.y, b.bg.x - b.ed.x, b.bg.y - b.ed.y);
		if (dblcmp(p, 0) == 0 && dblcmp(q, 0) == 0){
			printf("LINE\n");
		}else if (dblcmp(t, 0) == 0){
			printf("NONE\n");
		}else{
			p = VecPro(b.ed.x - b.bg.x, b.ed.y - b.bg.y, a.bg.x - b.bg.x, a.bg.y - b.bg.y);
			p = p / t;
			o.x = a.bg.x + p * (a.ed.x - a.bg.x);
			o.y = a.bg.y + p * (a.ed.y - a.bg.y);
			printf("POINT %0.2f %0.2f\n", o.x, o.y);
		}
	}
	printf("END OF OUTPUT\n");
	return 0;
}



在昇腾910B服务上部署搭建适配PDF解析工具Mineru2.5开源项目 本文介绍了在昇腾910B服务器上部署开源PDF解析工具Mineru2.5的过程。首先从昇腾社区下载mindie镜像并运行容器,安装系统依赖。针对部署过程中遇到的多个报错问题(如torchvision与torch版本不匹配、昇腾软件栈与NumPy 2.0不兼容等),提供了具体解决方案和兼容版本。通过设置环境变量、安装指定版本的Python依赖包,成功部署Mineru项目并下载模型。最后运行测试,验证了在NPU设备上运行pipeline的可行性。整个过程详细记录了版本适配和错误处理方法,为类似部署场景提供了参考 阅读详情

相关推荐

【ADCU详解】PMIC电源管理集成电路详解

自动驾驶域控制器(ADCU)中的电源管理集成电路(PMIC)是高度集成的关键部件,负责为计算核心、传感器等提供高效稳定的多路电源。其核心特点包括:符合车规AEC-Q100标准、支持功能安全ASIL等级、精确的时序控制及强抗干扰能力。PMIC由开关稳压器、LDO、时序控制器、监控保护电路等模块组成,通过分层电源树框架实现电能分配。设计需考虑效率、功率密度、噪声性能等关键维度,底层基于Buck转换器和LDO原理工作。使用中需满足严苛的车规环境要求,并通过静态/动态测试及故障注入测试进行验证,确保系统可靠性和安全

qq_40844444的博客 848

poj 1269 Intersecting Lines

Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000KB   64bit IO Format: %I64d & %I64u [Submit]

codeStone 1019

告别手动连接!一键搞定Mumu模拟器与Android Studio的ADB配置

本文详细介绍了如何通过编写自动化脚本,一键完成Mumu模拟器与Android Studio的ADB连接配置。告别繁琐的手动命令输入,该脚本能智能检查环境、判断连接状态并自动处理端口转发,显著提升Android开发者的调试与测试效率。

yog99的博客 502

Intersecting Lines

Intersecting Lines Time Limit:1000MS Memory Limit:65536K Total Submit:13 Accepted:4 Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines o...

weixin_30699741的博客 109

BrainVision Recorder 和 BrainVision Analyzer 2.2 安装

本篇为《EEG处理》系列博客的第二篇,该系列博客主要记录EEG信号处理的学习过程中的软件安装和学习过程,方便以后查阅。本篇为BrainVision Recorder 和 BrainVision Analyzer 2.2 的安装过程。 BrainVision Recorder 和 BrainVision Analyzer 2.2 安装安装前奏Brain Vision Analyzer分析软件 安装Brain Vision Recorder记录软件 安装推荐几款个人使用的科研软件 安装前奏 Brain V

梁小憨憨的博客 5074

5G移动性管理实战:手把手教你配置NR小区重选参数(附避坑指南)

本文深入解析5G网络移动性管理中的小区重选参数配置实战。通过拆解小区选择与重选的核心机制,结合真实案例,手把手指导如何配置NR小区重选参数,并分享常见避坑指南,帮助工程师优化网络性能,提升用户移动体验。

weixin_29229261的博客 201

poj 2653 Intersecting Lines

题目链接:http://poj.org/problem?id=1269 题目大意:给定两条直线,判断两条直线共线、平行、相交。若相交,求出交点。 思路:考察叉积的应用。 #include #include #include using namespace std; const int INF = 100010; struct Point { int x, y; }; Poi

c的专栏 577

红薯游客小眼睛接口分析与Python脚本实现

小眼睛接口与请求流程分析,使用Python实现小眼睛+1

吴秋霖的博客 2634

zzuli 1090 Intersecting Lines(几何问题)

题目链接:http://acm.zzuli.edu.cn/showproblem?problem_id=1090 本题很简单,但不知道为什么,只有一个人做,大意就是求平面内2条直线的关系,a,重合,b,平行,c,相交:此题有一点注意的地方就是,要知道当斜率不存在时注意处理; 代码如下: View Code #include <stdio.h>#include &...

157

UG\NX二次开发 获取对象的引用集

获取对象的引用集,一个对象可能有多个引用集,下面这个封装函数可以获取对象的所有引用集。

王牌飞行员_里海的博客 496

uniapp [安卓苹果App端] - 实现集成微信一键登录及授权获取用户信息全流程源码,uniApp唤起微信客户端app实现微信授权头像昵称手机号(提供移动应用/开放平台/资质认证/签名/权限申请

uni-app,安卓Android,苹果ios,安卓app端,苹果App端,uniapp苹果安卓app,微信一键登录,uniapp项目App端实现微信登录,Uniapp实现微信授权登录,调起微信客户端授权用户信息,uniappapp端微信一键登录打开手机微信app,app端如何唤起用户本机微信应用并授权登陆,如何申请微信一键登录,uniapp实现APP微信登录流程,打开本地微信软件,接入微信登录,UniApp实现微信登录教程,获取头像昵称手机号用户数据,超详细实现微信登录功能,唤起没反应,授权失败,获取

🏆 前端领域优质创作者 1万+

poj1254Hansel and Grethel poj1269Intersecting_Lines

poj1254Hansel and Grethel #include #include #include using namespace std; const double eps=1e-10; const double pi=acos(-1.0); const int inf=1e8; inline int dcmp(double x){ if(x < eps) return 0

coder_coder_coder的专栏 430

基于FPGA的万兆以太网学习(1)

万兆(10G) 以太网测速视频:SFP+屏蔽笼可以插入千兆或万兆光模块。SFP+信号定义与 SFP 一致。

baidu_34971492的博客 2255

Intersecting Lines POJ - 1269

http://poj.org/problem?id=1269 叉积真的是计算几何利器 首先对于两条直线(p1 p2) (p3 p4) 若两直线共线 则p3-p1与p2-p1的叉积模为0且p4-p1与p2-p1的叉积模为0 否则 用斜率判一下平行 最后 如果相交求交点 设交点为p0 则p1-p0与p2-p0的叉积模为0p3-p0与p4-p0的叉积模为0 联立后可得a1*x+b1*y+c1...

sunyutian1998的博客 240

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

(计算几何)POJ1269Intersecting Lines

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

Z7784562的博客 231

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

poj1269 Intersecting Lines

题目描述: vjudge POJ 题解: 直线判交没啥好说的…… (不要用g++,一定要用c++) 代码: #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const dou...

a6t2007的博客 179

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

POJ 1269 Intersecting Lines

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

Ever_glow的博客 742

【计算几何】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 2430 Lazy Cows
下一篇: POJ3304 Segments
cmonkey
博客等级 码龄17年 50粉丝 47原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值