Helper function for point conversion
3759
def to_debug_point(self, point: Union[Unit, Point2, Point3]) -> common_pb.Point:
        
        if isinstance(point, Unit):
            point = point.position3d
        return common_pb.Point(x=point.x, y=point.y, z=getattr(point, "z", 0))
335535
def move_point_num(point, to_clust, from_clust, cl_attr_sum, cl_memb_sum):
    """"""
    # Update sum of attributes in cluster.
    for iattr, curattr in enumerate(point):
        cl_attr_sum[to_clust][iattr] += curattr
        cl_attr_sum[from_clust][iattr] -= curattr
    # Update sums of memberships in cluster
    cl_memb_sum[to_clust] += 1
    cl_memb_sum[from_clust] -= 1
    return cl_attr_sum, cl_memb_sum
1026422
function readPointGeometry(object, scale, translate) {
  const coordinates = object['coordinates'];
  if (scale && translate) {
    transformVertex(coordinates, scale, translate);
  }
  return new Point(coordinates);
}
527934
def point(u, v)
      Util3D.check_arg_type(::Numeric, u)
      Util3D.check_arg_type(::Numeric, v)
      return base_point + u_vector*u + v_vector*v
    end
168165
function(points, callback, fromIndex, toIndex) {
	var newPoints = [], i, len;
	try {
		for (i = 0, len = points.length; i < len; i++) {
			if (!points[i].lat || !points[i].lng) {
				continue;
			}
			newPoints.push(points[i]);
		}
		calculateFromGPX(newPoints, callback, fromIndex, toIndex);
	} catch(e) {
		callback(e, null);
	}
}
461253
function (points, width) {
		// points format: [M, 0, 0, L, 100, 0]
		// normalize to a crisp line
		if (points[1] === points[4]) {
			points[1] = points[4] = mathRound(points[1]) + (width % 2 / 2);
		}
		if (points[2] === points[5]) {
			points[2] = points[5] = mathRound(points[2]) + (width % 2 / 2);
		}
		return points;
	}
358906
def _scalePoints(points, scale=1, convertToInteger=True):
    
    if convertToInteger:
        points = [
            (int(round(x * scale)), int(round(y * scale)))
            for (x, y) in points
        ]
    else:
        points = [(x * scale, y * scale) for (x, y) in points]
    return points
963842
function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {
		return (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);
	}
307963
def convertor(geometry, method="wgs2gcj"):
    
    if geometry['type'] == 'Point':
        coords = geometry['coordinates']
        coords[0], coords[1] = methods[method](coords[0], coords[1])
    elif geometry['type'] == 'LineString' or geometry['type'] == 'MutliPoint':
        coordinates = geometry['coordinates']
        for coords in coordinates:
            coords[0], coords[1] = methods[method](coords[0], coords[1])
    elif geometry['type'] == 'Polygon' or geometry['type'] == 'MultiLineString':
        coordinates = geometry['coordinates']
        for rings in coordinates:
            for coords in rings:
                coords[0], coords[1] = methods[method](coords[0], coords[1])
    elif geometry['type'] == 'MultiPolygon':
        coordinates = geometry['coordinates']
        for rings in coordinates:
            for lines in rings:
                for coords in lines:
                    coords[0], coords[1] = methods[method](coords[0], coords[1])
    return geometry
1205121
def point8_to_box(points):
    
    p = points.reshape((-1, 4, 2))
    minxy = p.min(axis=1)   # nx2
    maxxy = p.max(axis=1)   # nx2
    return np.concatenate((minxy, maxxy), axis=1)
67935
function toPoint(p, s, d) {
      return [
        p[0] + s * d[0],
        p[1] + s * d[1]
      ];
    }
1368615
def pointlist(points, sr):
    """"""
    assert all(isinstance(pt, Point) or len(pt) == 2 
               for pt in points), "Point(s) not in [x, y] form"
    return [coord if isinstance(coord, Point) 
                  else Point(coord[0], coord[1], sr)
            for coord in points]
122668
def _convertPointsToSegments(points, willBeReversed=False):
    
    # get the last on curve
    previousOnCurve = None
    for point in reversed(points):
        if point.segmentType is not None:
            previousOnCurve = point.coordinates
            break
    assert previousOnCurve is not None
    # gather the segments
    offCurves = []
    segments = []
    for point in points:
        # off curve, hold.
        if point.segmentType is None:
            offCurves.append(point)
        else:
            segment = InputSegment(
                points=offCurves + [point],
                previousOnCurve=previousOnCurve,
                willBeReversed=willBeReversed
            )
            segments.append(segment)
            offCurves = []
            previousOnCurve = point.coordinates
    assert not offCurves
    return segments
866471
function closestPoint1d(a, b, x, result) {
  var denom = 0.0;
  var numer = 0.0;
  for(var i=0; i<x.length; ++i) {
    var ai = a[i];
    var bi = b[i];
    var xi = x[i];
    var dd = ai - bi;
    numer += dd * (xi - bi);
    denom += dd * dd;
  }
  var t = 0.0;
  if(Math.abs(denom) > EPSILON) {
    t = numer / denom;
    if(t < 0.0) {
      t = 0.0;
    } else if(t > 1.0) {
      t = 1.0;
    }
  }  
  var ti = 1.0 - t;
  var d = 0;
  for(var i=0; i<x.length; ++i) {
    var r = t * a[i] + ti * b[i];
    result[i] = r;
    var s = x[i] - r;
    d += s * s;
  }
  return d;
}
548202
def point2upoint(point):
    """"""
    upoint = [set(), set()]
    for v, val in point.items():
        upoint[val].add(v.uniqid)
    upoint[0] = frozenset(upoint[0])
    upoint[1] = frozenset(upoint[1])
    return tuple(upoint)
168845
def from_scene_coords(self, x=0, y=0):
        """"""
        matrix = self.get_matrix()
        matrix.invert()
        return matrix.transform_point(x, y)
75140
function(point, bbox) {
        return inRange(point[0], bbox[0][0], bbox[1][0])
                && inRange(point[1], bbox[0][1], bbox[1][1]);
        function inRange(val, a, b) {
            return (val - a) * (val - b) <= 0;
        }
    }