Compute the distance of a point to a line (not the segment) defined by `p1` and `p2`.
5536
def pointToLineDistance(p, p1, p2):
    """"""
    d = np.sqrt(vtk.vtkLine.DistanceToLine(p, p1, p2))
    return d
136579
function (line, dist) {
        var sum = 0;

        if (dist <= 0) return line[0];

        for (var i = 0; i < line.length - 1; i++) {
            var p0 = line[i];
            var p1 = line[i + 1];
            var d = this.distance(p0, p1);
            sum += d;
            if (sum > dist) return interpolate(p0, p1, (dist - (sum - d)) / d);
        }

        return line[line.length - 1];
    }
935123
def pointIsBetween(startP, endP, p):
    
    return (distancePoint(startP, p) + distancePoint(p, endP)
            - distancePoint(startP, endP) < 1e-6)
1221009
def get_pixel_distance(self, x1, y1, x2, y2):
        
        dx = abs(x2 - x1)
        dy = abs(y2 - y1)
        dist = np.sqrt(dx * dx + dy * dy)
        dist = np.round(dist)
        return dist
54985
def get_closest_point_to_line(A, B, P):
    '''
    
    '''
    AP = XYPoint(P.x - A.x, P.y - A.y)
    AB = XYPoint(B.x - A.x, B.y - A.y)
    ab2 = AB.x * AB.x + AB.y * AB.y
    ap_ab = AP.x * AB.x + AP.y * AB.y
    t = ap_ab / ab2

    if t < 0.0:
        t = 0.0
    elif t > 1.0:
        t = 1.0

    return XYPoint(A.x + AB.x * t, A.y + AB.y * t)
189131
function getSqDist(p1, p2) {

    var dx = p1.x - p2.x,
        dy = p1.y - p2.y;

    return dx * dx + dy * dy;
}
355917
function(p, opt) {

            var segments = this.segments;
            var numSegments = segments.length;
            if (numSegments === 0) return null; // if segments is an empty array

            opt = opt || {};
            var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;
            var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;
            // not using localOpt

            var closestPointT;
            var minSquaredDistance = Infinity;
            for (var i = 0; i < numSegments; i++) {

                var segment = segments[i];
                var subdivisions = segmentSubdivisions[i];

                if (segment.isVisible) {
                    var segmentClosestPointT = segment.closestPointT(p, { precision: precision, subdivisions: subdivisions });
                    var segmentClosestPoint = segment.pointAtT(segmentClosestPointT);
                    var squaredDistance = (new Line(segmentClosestPoint, p)).squaredLength();

                    if (squaredDistance < minSquaredDistance) {
                        closestPointT = { segmentIndex: i, value: segmentClosestPointT };
                        minSquaredDistance = squaredDistance;
                    }
                }
            }

            if (closestPointT) return closestPointT;

            // if no visible segment, return end of last segment
            return { segmentIndex: numSegments - 1, value: 1 };
        }
720294
def distance2_to(self, other: "Point2"):
        """"""
        assert isinstance(other, Point2)
        return (self[0] - other[0]) ** 2 + (self[1] - other[1]) ** 2
998491
def distance_to_point2(self, p2: "Point2") -> Union[int, float]:
        
        return ((self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2) ** 0.5
310430
def distance_to(self, p: Union["Unit", Point2, Point3], bot: "BotAI" = None) -> Union[int, float]:
        
        if bot and isinstance(p, Unit):
            index = bot.distances_tag_dict
            return (bot.unit_distances_dict[index[self.tag]][index[p.tag]]) ** 0.5
        return self.position.distance_to_point2(p.position)
264680
private static double getSqDist(Point p1, Point p2) {
    double dx = p1.longitude() - p2.longitude();
    double dy = p1.latitude() - p2.latitude();
    return dx * dx + dy * dy;
  }
388994
def fast_distance(r1: 'Region', r2: 'Region'):
        
        return abs(r1.x - r2.x) + abs(r1.y - r2.y)
398822
def points_distance(x1, y1, x2, y2)
      Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
    end
84778
def distance_to(self, other):
        """"""

        other_coord = self._arith_check(other)
        return math.sqrt(math.pow(self._x - other_coord._x, 2) +
                         math.pow(self._y - other_coord._y, 2))
608190
def vector(p1, p2):
    
    return None if len(p1) != len(p2) else np.array([p2[i] - p1[i] for i in xrange(len(p1))])
1359976
function(p1, p2)
	{
		var min = Math.min(p1.length, p2.length);
		var comp = 0;
		
		for (var i = 0; i < min; i++)
		{
			if (p1[i] != p2[i])
			{
				if (p1[i].length == 0 ||
					p2[i].length == 0)
				{
					comp = (p1[i] == p2[i]) ? 0 : ((p1[i] > p2[i]) ? 1 : -1);
				}
				else
				{
					var t1 = parseInt(p1[i]);
					var t2 = parseInt(p2[i]);
					
					comp = (t1 == t2) ? 0 : ((t1 > t2) ? 1 : -1);
				}
				
				break;
			}
		}
		
		// Compares path length if both paths are equal to this point
		if (comp == 0)
		{
			var t1 = p1.length;
			var t2 = p2.length;
			
			if (t1 != t2)
			{
				comp = (t1 > t2) ? 1 : -1;
			}
		}
		
		return comp;
	}
396258
def ApproximateDistanceBetweenStops(stop1, stop2):
  """"""
  if (stop1.stop_lat is None or stop1.stop_lon is None or
      stop2.stop_lat is None or stop2.stop_lon is None):
    return None
  return ApproximateDistance(stop1.stop_lat, stop1.stop_lon,
                             stop2.stop_lat, stop2.stop_lon)