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
และ เราจะได้ว่า ถ้าเส้นตรงทั้งสองสอดคล้องเงื่อนไข แล้วเส้นทั้งสองจะขนานกัน
and we have the condition . 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.
เริ่มต้นมี เส้นตรงสองเส้น กับ
จะต้องสอดคล้องเงื่อนไขต่อไปนี้
- and
- and
- and
- and
อย่างน้อย 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.*

