Shortest distance between two line segments

This is my solution in Python. Works with 3d points and you can simplify for 2d. import numpy as np def closestDistanceBetweenLines(a0,a1,b0,b1,clampAll=False,clampA0=False,clampA1=False,clampB0=False,clampB1=False): ”’ Given two lines defined by numpy.array pairs (a0,a1,b0,b1) Return the closest points on each segment and their distance ”’ # If clampAll=True, set all clamps to True if clampAll: clampA0=True clampA1=True clampB0=True …

Read more

Algorithm to compute a Voronoi diagram on a sphere?

Update in July 2016: Thanks to a number of volunteers (especially Nikolai Nowaczyk and I), there is now far more robust / correct code for handling Voronoi diagrams on the surface of a sphere in Python. This is officially available as scipy.spatial.SphericalVoronoi from version 0.18 of scipy onwards. There’s a working example of usage and …

Read more