当前位置:网站首页>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)
边栏推荐
- 【Try to Hack】vulnhub DC4
- Euler function: find the number of numbers less than or equal to N and coprime with n
- ISO 27001 Information Security Management System Certification
- Mujoco's biped robot Darwin model
- How to retrieve the password for opening Excel files
- Win10+vs2019 Community Edition compiling OpenSSL
- The method of real-time tracking the current price of London Silver
- L'ouverture d'un compte d'actions en ligne est - elle sécurisée? Fiable?
- ZABBIX alarm execute remote command
- Android development interview was badly hit in 3 years, and now the recruitment technical requirements are so high?
猜你喜欢

Cassette helicopter and alternating electric field magnetic manometer DPC

Growing up in the competition -- (Guangyou's most handsome cub) Pikachu walking

Cloud computing - make learning easier

Quick foundation of group theory (5): generators, Kelley graphs, orbits, cyclic graphs, and "dimensions" of groups?

The method of real-time tracking the current price of London Silver

Mujoco model learning record

Review Net 20th anniversary development and 51aspx growth

Penetration practice vulnhub range Tornado

Oracle TRUNC function processing date format
![[PHP foundation] realize the connection between PHP and SQL database](/img/eb/c8953eddfe3b19b0adb5529957d275.jpg)
[PHP foundation] realize the connection between PHP and SQL database
随机推荐
Localization through custom services in the shuttle application
[2. Basics of Delphi grammar] 4 Object Pascal operators and expressions
APK签名流程介绍[通俗易懂]
ArrayList扩容详解
The difference and relationship between iteratible objects, iterators and generators
Xia CaoJun ffmpeg 4.3 audio and video foundation to engineering application
Is it reasonable and safe to open a securities account for 10000 shares free of charge? How to say
What are the six steps of the software development process? How to draw software development flow chart?
Session layer of csframework, server and client (1)
期货账户的资金安全吗?怎么开户?
Extract the compressed package file and retrieve the password
The latest intelligent factory MES management system software solution
Data warehouse (3) star model and dimension modeling of data warehouse modeling
ACL 2022 | decomposed meta learning small sample named entity recognition
Basic usage of shell script
About selenium element positioning being overwritten
[PHP foundation] realize the connection between PHP and SQL database
Function, condition, regular expression
Fix the problem that easycvr device video cannot be played
t10_ Adapting to Market Participantsand Conditions