Translates a unit position to a known parking spot

    Args:
        unit_pos: unit position as Vec2

    Returns: ParkingSpot object
185825
def unit_pos_to_spot(unit_pos) -> ParkingSpot:
    
    min_ = 50
    res = None
    for airport in parkings:
        for spot in parkings[airport]:  # type: ignore
            spot_pos = parkings[airport][spot]  # type: ignore
            dist = math.hypot(unit_pos[0] - spot_pos[0], unit_pos[1] - spot_pos[1])
            if dist < min_:
                min_ = dist  # type: ignore
                res = ParkingSpot(airport=airport, spot=spot)
    return res
908379
def update_pos(pos_dict, start_key, nbr=2):
    ""
    for key,idx in pos_dict.items():
        if str.lower(key) >= str.lower(start_key): pos_dict[key] += nbr
    return pos_dict
1360079
def window_locations(pos, windows):
    
    start_locs = np.searchsorted(pos, windows[:, 0])
    stop_locs = np.searchsorted(pos, windows[:, 1], side='right')
    locs = np.column_stack((start_locs, stop_locs))
    return locs
205489
def convert_point(self, point):
        '''
        
        '''
        return self.container.convert_point(Vector(point) + self.pos)
355763
def translate(compound, pos):
    
    atom_positions = compound.xyz_with_ports
    atom_positions = Translation(pos).apply_to(atom_positions)
    compound.xyz_with_ports = atom_positions
930839
def initPos(self, startpos=0.0):
        
        spos = startpos
        for ele in self._lattice_eleobjlist:
            # print("{name:<10s}: {pos:<10.3f}".format(name=ele.name, pos=spos))
            ele.setPosition(spos)
            spos += ele.getLength()
744990
def parse_v3_unit_placement(placement_str):
    
    placement = placement_str
    container = machine = service = unit = ''
    if ':' in placement:
        try:
            container, placement = placement_str.split(':')
        except ValueError:
            msg = 'placement {} is malformed, too many parts'.format(
                placement_str)
            raise ValueError(msg.encode('utf-8'))
    if '=' in placement:
        try:
            placement, unit = placement.split('=')
        except ValueError:
            msg = 'placement {} is malformed, too many parts'.format(
                placement_str)
            raise ValueError(msg.encode('utf-8'))
    if placement.isdigit():
        machine = placement
    else:
        service = placement
    if (container and container not in VALID_CONTAINERS):
        msg = 'invalid container {} for placement {}'.format(
            container, placement_str)
        raise ValueError(msg.encode('utf-8'))
    unit = _parse_unit(unit, placement_str)
    if machine and machine != '0':
        raise ValueError(b'legacy bundles may not place units on machines '
                         b'other than 0')
    return UnitPlacement(container, machine, service, unit)
548702
function orthoProj_(pos, cam){
    var vec = V3.sub(pos, cam.pos);
    var camAxis = axis(cam);
    var normDist = V3.dot(vec, camAxis.y);
    var normProj = V3.scale(normDist, camAxis.y);
    var posOnPlane = V3.add(vec, V3_(-normProj.x, -normProj.y, -normProj.z));
    var x = V3.dot(posOnPlane, camAxis.x);
    var y = V3.dot(posOnPlane, camAxis.z);
    return V3_(x, y, normDist);
  }
213781
def position
      return @__position if defined? @__position
      return @__position = nil unless params['pos'] =~ /^([NS])(\d+)\.(\d+)\.(\d+\.\d+)([WE])(\d+)\.(\d+)\.(\d+\.\d+)$/

      raise 'Unsupported datum' if params['geo'] != 'wgs84'

      l = Jpmobile::Position.new
      l.lat = ((Regexp.last_match(1) == 'N') ? 1 : -1) * Jpmobile::Position.dms2deg(Regexp.last_match(2), Regexp.last_match(3), Regexp.last_match(4))
      l.lon = ((Regexp.last_match(5) == 'E') ? 1 : -1) * Jpmobile::Position.dms2deg(Regexp.last_match(6), Regexp.last_match(7), Regexp.last_match(8))
      l.options = params.select {|x, _| ['pos', 'geo', 'x-acr'].include?(x) }

      @__position = l
    end
360533
def ic_pos(self, row1, row2=None):
        
        if row2 is None:
            row2 = [0.25,0.25,0.25,0.25]

        score = 0
        for a,b in zip(row1, row2):
            if a > 0:
                score += a * log(a / b) / log(2)
        return score
107588
def pos3(self):
        '''  '''
        parts = [self.pos]
        if self.sc1 and self.sc1 != '*':
            parts.append(self.sc1)
            if self.sc2 and self.sc2 != '*':
                parts.append(self.sc2)
        return '-'.join(parts)
437973
def near_to_position(self, position, max_distance):
        ''''''
        end = self.ref_end_pos()
        return self.POS <= position <= end or abs(position - self.POS) <= max_distance or abs(position - end) <= max_distance
1299787
def position
      return @__position if defined? @__position
      return @__position = nil if params['pos'].nil? || params['pos'] == ''
      raise 'unsupported format' unless params['pos'] =~ /^N(\d\d)\.(\d\d)\.(\d\d\.\d\d\d)E(\d\d\d)\.(\d\d)\.(\d\d\.\d\d\d)$/

      pos = Jpmobile::Position.new
      pos.lat = Jpmobile::Position.dms2deg(Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3))
      pos.lon = Jpmobile::Position.dms2deg(Regexp.last_match(4), Regexp.last_match(5), Regexp.last_match(6))
      pos.tokyo2wgs84!
      @__position = pos
    end
467755
@Pure
	public Point1d getNearestPosition(Point2D<?, ?> pos) {
		Point2d pp = null;
		final Vector2d v = new Vector2d();
		double currentPosition = 0.;
		double bestPosition = Double.NaN;
		double bestDistance = Double.POSITIVE_INFINITY;
		for (final Point2d p : points()) {
			if (pp != null) {
				double position = Segment2afp.findsProjectedPointPointLine(
						pos.getX(), pos.getY(),
						pp.getX(), pp.getY(),
						p.getX(), p.getY());
				if (position < 0.) {
					position = 0.;
				}
				if (position > 1.) {
					position = 1.;
				}
				v.sub(p, pp);
				final double t = v.getLength();
				v.scale(position);
				final double dist = Point2D.getDistanceSquaredPointPoint(
						pos.getX(),
						pos.getY(),
						pp.getX() + v.getX(),
						pp.getY() + v.getY());
				if (dist < bestDistance) {
					bestDistance = dist;
					bestPosition = currentPosition + v.getLength();
				}
				currentPosition += t;
			}
			pp = p;
		}
		if (Double.isNaN(bestPosition)) {
			return null;
		}
		return new Point1d(toSegment1D(), bestPosition, 0.);
	}
520886
def _points(self, x_pos):
        
        for serie in self.all_series:
            serie.points = [(x_pos[i], v) for i, v in enumerate(serie.values)]
            if serie.points and self.interpolate:
                serie.interpolated = self._interpolate(x_pos, serie.values)
            else:
                serie.interpolated = []
1192687
def addPos(self, dp_x=None, dy=None, dz=None):
        """"""
        p = np.array(self.GetPosition())
        if dz is None:  # assume dp_x is of the form (x,y,z)
            self.SetPosition(p + dp_x)
        else:
            self.SetPosition(p + [dp_x, dy, dz])
        if self.trail:
            self.updateTrail()
        return self
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)