![]() |
Determining the intersection point of the two lines is one of the fundamental problem in the computational geometry. This problem arises in various fields such as the computer graphics, robotics and geographic information systems. In this article, we will learn how to find whether two lines intersect each other or not and if they intersect, find out the point of intersection. Lines IntersectionIn 2D space, lines can be represented the mathematically as: Ax + By + C = 0 where,
To find their intersection, we first need to find whether the two lines ever intersect or not. We can do that using the determinant value that can be found by using the below formula: A1 * B2 - A2 * B1
Finding the Point of IntersectionThe algorithm for finding the intersection of the two lines involves solving the system of the linear equations that represent the lines. The equations of the two lines can be represented as: A1x +B1y + C1 = 0 A2x + B2y + C2 = 0 To find the intersection point (x, y) we need to the solve these equations as the value of x and y coordinate will be same for both equations. Refer to this article to know how to solve linear equation of two variable – Linear Equations Formula Approach
ImplementationHere is a complete C program to the find the intersection of the two lines:
Output Intersection point: (-1.00, 1.00) Time Complexity: O(1) Related Article: |
Reffered: https://www.geeksforgeeks.org
C Language |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |