Project logical coordinates to Java2D coordinates.
8773
public int[] screenProjection(double... coord) {
        double[] sc = new double[2];
        sc[0] = baseScreenCoords[0][0];
        sc[1] = baseScreenCoords[0][1];

        for (int i = 0; i < canvas.base.dimension; i++) {
            sc[0] += ((coord[i] - canvas.base.baseCoords[0][i]) / (canvas.base.baseCoords[i + 1][i] - canvas.base.baseCoords[0][i])) * (baseScreenCoords[i + 1][0] - baseScreenCoords[0][0]);
            sc[1] += ((coord[i] - canvas.base.baseCoords[0][i]) / (canvas.base.baseCoords[i + 1][i] - canvas.base.baseCoords[0][i])) * (baseScreenCoords[i + 1][1] - baseScreenCoords[0][1]);
        }

        return new int[]{(int) sc[0], (int) sc[1]};
    }
1023373
function pointToTile(lon, lat, z) {
    var tile = pointToTileFraction(lon, lat, z);
    tile[0] = Math.floor(tile[0]);
    tile[1] = Math.floor(tile[1]);
    return tile;
}
941549
def lat_to_deg(lat):
    """"""
    if isinstance(lat, str) and (':' in lat):
        # TODO: handle other coordinate systems
        lat_deg = dmsStrToDeg(lat)
    else:
        lat_deg = float(lat)
    return lat_deg
1050191
def moveToPoint(self, xxx_todo_changeme2):
        
        (x,y) = xxx_todo_changeme2
        self.set_x1(float(self.get_x1()) + float(x))
        self.set_x2(float(self.get_x2()) + float(x))
        self.set_y1(float(self.get_y1()) + float(y))
        self.set_y2(float(self.get_y2()) + float(y))
1108288
def from_pixel(cls, pixel_x=0, pixel_y=0, zoom=None):
        """"""
        max_pixel = (2 ** zoom) * TILE_SIZE
        assert 0 <= pixel_x <= max_pixel, 'Point X needs to be a value between 0 and (2^zoom) * 256.'
        assert 0 <= pixel_y <= max_pixel, 'Point Y needs to be a value between 0 and (2^zoom) * 256.'
        meter_x = pixel_x * resolution(zoom) - ORIGIN_SHIFT
        meter_y = pixel_y * resolution(zoom) - ORIGIN_SHIFT
        meter_x, meter_y = cls._sign_meters(meters=(meter_x, meter_y), pixels=(pixel_x, pixel_y), zoom=zoom)
        return cls.from_meters(meter_x=meter_x, meter_y=meter_y)
161453
def get_transformation(self, coordinates):
        """"""
        atom1, atom2, atom3, atom4 = self.hinge_atoms
        a = coordinates[atom1] - coordinates[atom2]
        a /= np.linalg.norm(a)
        b = coordinates[atom3] - coordinates[atom4]
        b /= np.linalg.norm(b)
        direction = 0.5*(a+b)
        direction *= np.random.uniform(-self.max_amplitude, self.max_amplitude)
        result = Translation(direction)
        return result
144315
private static double[] transformToLabelProjection(
            final MathTransform toLabelProjection,
            final Coordinate borderIntersection) {
        try {
            double[] labelProj = new double[2];
            toLabelProjection
                    .transform(new double[]{borderIntersection.x, borderIntersection.y}, 0, labelProj, 0, 1);
            return labelProj;
        } catch (TransformException e) {
            throw new RuntimeException(e);
        }
    }
428692
def _project_on_ellipsoid(c, r, locations):
    """"""
    p0 = locations - c  # original locations

    l2 = 1 / np.sum(p0**2 / r**2, axis=1, keepdims=True)
    p = p0 * np.sqrt(l2)  # initial approximation (projection of points towards center of ellipsoid)

    fun = lambda x: np.sum((x.reshape(p0.shape) - p0)**2)              # minimize distance between new and old points
    con = lambda x: np.sum(x.reshape(p0.shape)**2 / r**2, axis=1) - 1  # new points constrained to surface of ellipsoid
    res = sp.optimize.minimize(fun, p, constraints={'type': 'eq', 'fun': con}, method='SLSQP')

    return res['x'].reshape(p0.shape) + c
1179117
def compute_coordinate(self, index):
        ''''''
        j = index%self.board_size
        i = (index - j) // self.board_size
        return (i, j)
1259087
public static long[] coordinatesToHilbert(long[] coords, int bitsperdim, int offset) {
    final int numdim = coords.length;
    final int numbits = numdim * bitsperdim;
    final long[] output = BitsUtil.zero(numbits);

    int rotation = 0;
    long[] refl = BitsUtil.zero(numdim);
    for(int i = 0; i < bitsperdim; i++) {
      final long[] hist = interleaveBits(coords, i + offset);
      // System.err.println(BitsUtil.toString(hist,
      // numdim)+" rot:"+rotation+" refl: "+BitsUtil.toString(refl, numdim));
      final long[] bits = BitsUtil.copy(hist);
      BitsUtil.xorI(bits, refl);
      BitsUtil.cycleRightI(bits, rotation, numdim);
      final int nextrot = (rotation + BitsUtil.numberOfTrailingZerosSigned(bits) + 2) % numdim;
      BitsUtil.invgrayI(bits);
      BitsUtil.orI(output, bits, numbits - (i + 1) * numdim);
      // System.err.println(BitsUtil.toString(output,
      // numbits)+" bits: "+BitsUtil.toString(bits, numdim));
      refl = hist;
      BitsUtil.flipI(refl, rotation);
      if(!BitsUtil.get(bits, 0)) {
        BitsUtil.flipI(refl, (nextrot - 1 + numdim) % numdim);
      }
      rotation = nextrot;
    }

    return output;
  }
34934
def coordinates(self, x, y, **kwargs):
        ''''''
        kwargs['returntype'] = 'geographies'
        fields = {
            'x': x,
            'y': y
        }

        return self._fetch('coordinates', fields, **kwargs)
315504
def _coordinates_changed(self):
        """"""
        if self._are_coordinates_valid():
            point1 = QgsPointXY(
                self.x_minimum.value(),
                self.y_maximum.value())
            point2 = QgsPointXY(
                self.x_maximum.value(),
                self.y_minimum.value())
            rect = QgsRectangle(point1, point2)

            self.tool.set_rectangle(rect)
1354423
def set_coords(self, x=0, y=0, z=0, t=0):
        
        self.coords = {}
        self.coords['x'] = x
        self.coords['y'] = y
        self.coords['z'] = z
        self.coords['t'] = t
450539
public void projectOntoUnit(Vector2f b, Vector2f result) {
		float dp = b.dot(this);
		
		result.x = dp * b.getX();
		result.y = dp * b.getY();
		
	}
440445
def setCoords(self, x1, y1, x2, y2):
        """"""
        self.trans = Transform(self.size[0], self.size[1], x1, y1, x2, y2)
1223871
def _populate_coordinates(self):
        """"""
        rect = self.tool.rectangle()
        self.blockSignals(True)
        if not rect.isEmpty():
            self.x_minimum.setValue(rect.xMinimum())
            self.y_minimum.setValue(rect.yMinimum())
            self.x_maximum.setValue(rect.xMaximum())
            self.y_maximum.setValue(rect.yMaximum())
        else:
            self.x_minimum.clear()
            self.y_minimum.clear()
            self.x_maximum.clear()
            self.y_maximum.clear()
        self.blockSignals(False)
19212
function (x, y, v) {
            var ret = v || new me.Vector2d();

            var alignedX = x,
                alignedY = y;

            if (this.staggerX) {
                alignedX -= this.staggerEven ? this.sideoffsetx : 0;
            } else {
                alignedY -= this.staggerEven ? this.sideoffsety : 0;
            }

            // Start with the coordinates of a grid-aligned tile
            var referencePoint = me.pool.pull("me.Vector2d",
                Math.floor(alignedX / this.tilewidth),
                Math.floor(alignedY / this.tileheight)
            );

            // Adjust the reference point to the correct tile coordinates
            if (this.staggerX) {
                referencePoint.x = referencePoint.x * 2;
                if (this.staggerEven) {
                    ++referencePoint.x;
                }
            } else {
                referencePoint.y = referencePoint.y * 2;
                if (this.staggerEven) {
                    ++referencePoint.y;
                }
            }

            // Relative x and y position on the base square of the grid-aligned tile
            var rel = me.pool.pull("me.Vector2d",
                alignedX - referencePoint.x * this.tilewidth,
                alignedY - referencePoint.y * this.tileheight
            );

            // Check whether the cursor is in any of the corners (neighboring tiles)
            var y_pos = rel.x * (this.tileheight / this.tilewidth);

            if (this.sideoffsety - y_pos > rel.y) {
                referencePoint = this.topLeft(referencePoint.x, referencePoint.y, referencePoint);
            }
            if (-this.sideoffsety + y_pos > rel.y) {
                referencePoint = this.topRight(referencePoint.x, referencePoint.y, referencePoint);
            }
            if (this.sideoffsety + y_pos < rel.y) {
                referencePoint = this.bottomLeft(referencePoint.x, referencePoint.y, referencePoint);
            }
            if (this.sideoffsety * 3 - y_pos < rel.y) {
                referencePoint = this.bottomRight(referencePoint.x, referencePoint.y, referencePoint);
            }

            ret = this.tileToPixelCoords(referencePoint.x, referencePoint.y, ret);

            ret.set(x - ret.x, y - ret.y);

            // Start with the coordinates of a grid-aligned tile
            ret.set(
                ret.x - (this.tilewidth / 2),
                ret.y * (this.tilewidth / this.tileheight)
            );

            ret.div(this.tilewidth / Math.sqrt(2)).rotate(me.Math.degToRad(-45)).add(referencePoint);

            me.pool.push(referencePoint);
            me.pool.push(rel);

            return ret;
        }