当前位置:网站首页>Calculation of intersection of two line segments
Calculation of intersection of two line segments
2022-07-01 18:26:00 【zjjxFPGAer】
problem
Known line segments P1P2 and Q1Q2, Determine whether they have intersections , If you have any , Find the intersection point .
1. Judge whether line segments intersect
Pictured , Judge whether line segments intersect , It can be carried out through a series of experiments .
Rapid rejection experiment
If the P1P2 and Q1Q2 Rectangles that are diagonal do not intersect , be P1P2 It must not intersect
Only when
min(p1.x,p2.x) <= max(q1.x,q2.x)
min(q1.x,q2.x) <= max(p1.x,p2.x)
min(p1.y,p2.y) <= max(q1.y,q2.y)
min(q1.y,q2.y) <= max(p1.y,p2.y)
When all four formulas are satisfied , Two line segments can intersect , Otherwise, it will not intersect . This is Rapid rejection experiment .
Straddle experiment
According to the picture above , Even after passing the rapid rejection experiment , Two straight lines do not necessarily intersect , therefore , We need to further pass the so-called Straddle experiment Judge .
For this part, please refer to link
2. Calculation of intersection of line segments
set up P 1 ( x 1 , y 1 ) , P 2 ( x 2 , y 2 ) , Q 1 ( x 3 , y 3 ) , Q 2 ( x 4 , y 4 ) P_1(x_1,y_1),P_2(x_2,y_2),Q_1(x_3,y_3),Q_2(x_4,y_4) P1(x1,y1),P2(x2,y2),Q1(x3,y3),Q2(x4,y4), be P 1 P 2 P_1P_2 P1P2 and Q 1 Q 2 Q_1Q_2 Q1Q2 The intersection of is calculated as follows :
The reason why I think the straddle experiment is of little significance , It is because there is no great difference between the calculation of the straddle experiment and that of the direct calculation of the intersection , We can calculate the intersection of straight lines directly , Then judge whether the intersection is on the line segment , The criteria for judgment are as follows :
m a x ( x 1 , x 2 ) ≥ x o ≥ m i n ( x 1 , x 2 ) max(x_1,x_2)\ge x_o\ge min(x_1,x_2) max(x1,x2)≥xo≥min(x1,x2) m a x ( x 3 , x 4 ) ≥ x o ≥ m i n ( x 3 , x 4 ) max(x_3,x_4)\ge x_o\ge min(x_3,x_4) max(x3,x4)≥xo≥min(x3,x4)
边栏推荐
- Glidefast consulting was selected as the elite partner of servicenow in 2022
- The method of real-time tracking the current price of London Silver
- EasyCVR通过国标GB28181协议接入设备,出现设备自动拉流是什么原因?
- Detailed explanation of select in golang
- Xia CaoJun ffmpeg 4.3 audio and video foundation to engineering application
- Check log4j problems using stain analysis
- Set the style of QT property sheet control
- The latest software scheme of the intelligent information management system of the armed police force
- Opencv map reading test -- error resolution
- EasyCVR设备录像出现无法播放现象的问题修复
猜你喜欢

Gold, silver and four job hopping, interview questions are prepared, and Ali becomes the champion

Definition of rotation axis in mujoco

Penetration practice vulnhub range Keyring

Highly reliable program storage and startup control system based on anti fuse FPGA and QSPI flash

Penetration practice vulnhub range Nemesis

Wechat applet blind box - docking wechat payment
![[beauty detection artifact] come on, please show your unique skill (is this beauty worthy of the audience?)](/img/e8/f43f5583e330fbc0cb6c0188711707.jpg)
[beauty detection artifact] come on, please show your unique skill (is this beauty worthy of the audience?)

Data query language (DQL)

What are the legal risks of NFT brought by stars such as curry and O'Neill?

Cassette helicopter and alternating electric field magnetic manometer DPC
随机推荐
New 95 community system whole station source code
What impact will multinational encryption regulation bring to the market in 2022
On the language internationalization of Yongzhong Office
Unity3d extended toolbar
June issue | antdb database participated in the preparation of the "Database Development Research Report" and appeared on the list of information technology and entrepreneurship industries
How to retrieve the password for opening Excel files
EasyCVR设备录像出现无法播放现象的问题修复
L'ouverture d'un compte d'actions en ligne est - elle sécurisée? Fiable?
APK签名流程介绍[通俗易懂]
Develop those things: add playback address authentication to easycvr platform
Slider verification code identification gadget display
EasyCVR通过国标GB28181协议接入设备,出现设备自动拉流是什么原因?
Length of learning and changing
[acnoi2022] color ball
Rotation order and universal lock of unity panel
MySQL -- explain performance optimization
ArrayList扩容详解
Is online stock account opening safe? Is it reliable?
Oracle TRUNC function processing date format
Data query language (DQL)