LEETCODE算法:16.03. Intersection LCCI
题目
Given two straight line segments (represented as a start point and an end point), compute the point of intersection, if any. If there's no intersection, return an empty array.
The absolute error should not exceed 10^-6. If there are more than one intersections, return the one with smallest X axis value. If there are more than one intersections that have same X axis value, return the one with smallest Y axis value. Example 1:
Input: line1 = {0, 0}, {1, 0} line2 = {1, 1}, {0, -1} Output: {0.5, 0} Example 2:
Input: line1 = {0, 0}, {3, 3} line2 = {1, 1}, {2, 2} Output: {1, 1} Example 3: