This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find a point that is mutually closest to two or more lines in a least-squares sense. | |
# Based on: https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#Nearest_point_to_non-intersecting_lines | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# Create two or more lines in the form of a matrix [[x1,y1], [x2,y2]] | |
lines = [] | |
lines.append(np.asmatrix([[4, 4], [4, -3]])) | |
lines.append(np.asmatrix([[3, 2], [10, 2]])) | |
lines.append(np.asmatrix([[3, 3], [6, 4]])) |
NewerOlder