Are two line segments crossing?

Are two line segments crossing?

​ในการตรวจสอบว่าส่วนของ​เส้นตรงสอง​เส้นตัดกันหรือ ​ไม่นั้น มัน​ไม่ง่าย​​​อย่างที่คิด จริง ๆ​ ​แล้วม​ันควรจะ​ง่าย​ขึ้นถ้าส่วนของ​เส้นตรงนั้น กลาย​มา​เป็น​เส้นตรง

Actually, to check whether two line segments are crossing is more difficult than you think. In fact, it ought to be easier if the line segments become lines.

ก่อนอื่น​เราจึงทำ​การลดรูปปัญหาน​ี้มา​เป็นปัญหาก​ารตัดกันของ​เส้นตรง

First, we reduce the form of this problem to be the problem whether or not two lines are crosing.

​อย่า ลืมว่า ​เรา​ไม่สน​ใจว่า จุดตัด​อยู่​ไหน ​เราสน​ใจ​แค่ว่ามันตัดกันหรือป่าว​ วิธีที่ง่าย​ที่สุดก็​คือตรวจสอบการขนาน​กันของ​เส้นทั้งสอง ซึ่งจะ​ทำ​​ได้ง่าย​มาก​ ​โดยดูจาก​ความชัน ของ​เส้นตรงนั้น

In this case, we don't pay attention to the cutting point(the point of intersection). We just interested in whether they are crossing or not. One of the easest ways is trying to check if they are parallel to each other. This is very simple and easy by checking the angle(tangent?) of the lines.

จาก​สมการ​เส้นตรง

From the linear equation

y = a 1 x + b 1 ​และ​ y = a 2 x + b 2 ​เราจะ​​ได้ว่า ถ้า​เส้นตรงทั้งสองสอดคล้อง​เงื่อน​ไข a 1 = a 2 ​แล้ว​เส้นทั้งสองจะ​ขนาน​กัน

y = a 1 x + b 1 and y = a 2 x + b 2 we have the condition a 1 = a 2 . If it satisfies the condition, then that two lines are parallel.

​แต่สำ​หรับส่วนของ​เส้นตรงนั้นมัน​ไม่ง่าย​​​อย่าง​แบบนี้ ​เพราะ​ว่า​เส้นที่​ไม่ขนาน​กันก็​อาจจะ​​ไม่ตัดกันก็​​ได้

But for the case of line segments, it is not easy like this, because two non-parallel line segments may not be crossing.

วิธีที่ง่าย​ที่สุดคือ คำ​นวนหาจุดตัดซะ​ ถ้าจุดตัดนั้น​อยู่บน ​เส้นทั้งสอง ก็​​แสดงว่า มันตัดกัน ​แต่ถ้า​ไม่​อยู่ก็​​แสดงว่า มัน ​ไม่ตัดกัน

The easiest way is to find the cutting point and check whether the cutting point is on that two lines.

วิธีนี้มีข้อ​เสียคือ ​เราต้อง​แก้สมการ​เพื่อหาจุดตัด ​และ​ มาทดสอบว่า​อยู่บน​เส้นทั้งสองอีก ด้วย​หรือ​ไม่

But this solution has some disadvantage that we must solve the system of linear equations and check if the point is on both lines or not.

อีกวิธีหนึ่งคือ วิธี​แบ่งครึ่งระ​นาบ ​โดยอาศัยหลักการที่ว่าถ้า ส่วนของ​เส้นตรงสอง​เส้นตัดกัน ​แล้ว​แต่ละ​ครึ่งระ​นาบ ของ ​แต่ละ​​เส้น จะ​มีจุดปลาย​จาก​อีก​เส้น​อยู่​แค่จุด​เดียว

Another solution is to find half spaces of the lines and check the end points of the lines if it is on the same half space or not.

ฟังดูยาก​ ​แต่สรุป​เป็น​เงื่อน​ไขง่าย​ ๆ​ ​ได้ดังนี้

It sounds difficult but In fact it can be summarized into 4 easy conditions.

​เริ่มต้นมี ​เส้นตรงสอง​เส้น ( x 1 , y 1 ) , ( x 2 , y 2 ) กับ ( x 3 , y 3 ) , ( x 4 , y 4 ) a 1 = y 2 - y 1 b 1 = x 2 y 1 - x 1 y 2 c 1 = x 2 - x 1

a 2 = y 4 - y 2 b 2 = x 4 y 2 - x 4 y 2 c 2 = x 4 - x 2

จะ​ต้องสอดคล้อง​เงื่อน​ไขต่อ​ไปนี้

  1. a 1 x 3 + b 1 y 3 and a 1 x 4 + b 1 y 4
  2. a 1 x 3 + b 1 y 3 and a 1 x 4 + b 1 y 4
  3. a 2 x 1 + b 2 y 1 and a 2 x 2 + b 2 y 2
  4. a 2 x 1 + b 2 y 1 and a 2 x 2 + b 2 y 2

​​อย่างน้อย 2 ข้อ จึงสรุป​ได้ว่า มีการตัดกัน

If it satifies at least 2 conditions above, we conclude that they are crossing each other.

  • ps. I try to use this to improve my English proficiency, not to be laugh at.*
4
Your rating: None Average: 4 (2 votes)

Relevant Content