当前位置:网站首页>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)
边栏推荐
- Kernel stray cat stray dog pet adoption platform H5 source code
- How to retrieve the password for opening Excel files
- Domestic spot silver should be understood
- Is online stock account opening safe? Is it reliable?
- Vue uses keep alive to cache page optimization projects
- APK签名流程介绍[通俗易懂]
- ArrayList扩容详解
- 2022 Heilongjiang latest fire protection facility operator simulation test question bank and answers
- SCP -i private key usage
- Cloud computing - make learning easier
猜你喜欢

Mujoco model learning record

The difference and relationship between iteratible objects, iterators and generators

Bug of QQ browser article comment: the commentator is wrong

Intel's open source deep learning tool library openvino will increase cooperation with local software and hardware parties and continue to open

Data warehouse (3) star model and dimension modeling of data warehouse modeling

How to retrieve the password for opening Excel files

Fix the black screen caused by iPhone system failure

Common design parameters of solid rocket motor

Kernel stray cat stray dog pet adoption platform H5 source code

Database - MySQL advanced SQL statement (I)
随机推荐
Win10+vs2019 Community Edition compiling OpenSSL
Step size of ode45 and reltol abstol
Batch export all pictures in PPT in one second
[acnoi2022] color ball
The method of real-time tracking the current price of London Silver
Penetration practice vulnhub range Tornado
People help ant help task platform repair source code
APK签名流程介绍[通俗易懂]
The latest intelligent factory MES management system software solution
Is the software of futures pioneer formal and safe? Which futures company is safer to choose?
To improve the efficiency of office collaboration, trackup may be the best choice
Mujoco XML modeling
Flex layout
PIP version problems: PIP problems still occur when installing akshare and using Tsinghua source and Douban source
MySQL -- explain performance optimization
Mujoco model learning record
Redis -- data type and operation
证券开户安全么,有没有什么样的危险呢
540. Single element in ordered array
Subnet division and summary