Project coordinates on sphere to image plane using Projector class.
519637
def project(self, projector = None):
        
        msg = "'%s.project': ADW 2018-05-05"%self.__class__.__name__
        DeprecationWarning(msg)
        if projector is None:
            try:
                self.projector = ugali.utils.projector.Projector(self.config['coords']['reference'][0],
                                                                 self.config['coords']['reference'][1])
            except KeyError:
                logger.warning('Projection reference point is median (lon, lat) of catalog objects')
                self.projector = ugali.utils.projector.Projector(np.median(self.lon), np.median(self.lat))
        else:
            self.projector = projector

        self.x, self.y = self.projector.sphereToImage(self.lon, self.lat)
89714
def de_projection_3d(amplitudes, sigmas):
    
    amplitudes_3d = amplitudes / sigmas / np.sqrt(2*np.pi)
    return amplitudes_3d, sigmas
820017
def project_point(cb, msg, attributes=('x', 'y')):
    
    if skip(cb, msg, attributes): return msg
    plot = get_cb_plot(cb)
    x, y = msg.get('x', 0), msg.get('y', 0)
    crs = plot.current_frame.crs
    coordinates = crs.transform_points(plot.projection, np.array([x]), np.array([y]))
    msg['x'], msg['y'] = coordinates[0, :2]
    return {k: v for k, v in msg.items() if k in attributes}
352048
def native_projection_explanation(ax):
    """"""
    ax.set_title('Longitude and Latitude', size=18, y=1.1)

    # Hide the azimuth labels
    ax.set_azimuth_ticklabels([])

    # Make the axis tick labels visible:
    ax.set_xticks(np.radians(np.arange(-80, 90, 10)))
    ax.tick_params(label1On=True)

    ax.set_xlabel('Longitude')

    xlabel_halo(ax)
    return ax
806715
public void project(double x, double y, double z, double[] out) {
    glu.gluProject(x, y, z, modelview, 0, projection, 0, viewp, 0, out, 0);
  }
878780
void computeProjectionTable( int width , int height ) {
		output.reshape(width,height);
		depthMap.reshape(width,height);

		ImageMiscOps.fill(depthMap,-1);

		pointing = new float[width*height*3];

		for (int y = 0; y < output.height; y++) {
			for (int x = 0; x < output.width; x++) {
				// Should this add 0.5 so that the ray goes out of the pixel's center? Seems to increase reprojection
				// error in calibration tests if I do...
				pixelTo3.compute(x, y, p3);
				if(UtilEjml.isUncountable(p3.x)) {
					depthMap.unsafe_set(x,y,Float.NaN);
				} else {
					pointing[(y*output.width+x)*3   ] = (float)p3.x;
					pointing[(y*output.width+x)*3+1 ] = (float)p3.y;
					pointing[(y*output.width+x)*3+2 ] = (float)p3.z;
				}
			}
		}
	}
1240797
function setProjection( element, options ) {
    var width = options.width || element.offsetWidth;
    var height = options.height || element.offsetHeight;
    var projection, path;
    if ( options && typeof options.scope === 'undefined') {
      options.scope = 'world';
    }

    if ( options.scope === 'usa' ) {
      projection = d3.geo.albersUsa()
        .scale(width)
        .translate([width / 2, height / 2]);
    }
    else if ( options.scope === 'world' ) {
      projection = d3.geo[options.projection]()
        .scale((width + 1) / 2 / Math.PI)
        .translate([width / 2, height / (options.projection === "mercator" ? 1.45 : 1.8)]);
    }

    path = d3.geo.path()
      .projection( projection );

    return {path: path, projection: projection};
  }
156258
function verticesProjection(vertices, axis) {
      const [p1, p2, p3, p4] = vertices.map(v => axis.dot(new Vector(v)));

      return [Math.min(p1, p2, p3, p4), Math.max(p1, p2, p3, p4)];
    }
511776
def raster_to_projection_coords(self, pixel_x, pixel_y):
        
        h_px_py = np.array([1, pixel_x, pixel_y])
        gt = np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]])
        arr = np.inner(gt, h_px_py)
        return arr[2], arr[1]
1015685
void buildLinePortion(final Projection pProjection,
						  final boolean pStorePoints){
		final int size = mOriginalPoints.size();
		if (size < 2) { // nothing to paint
			return;
		}
        computeProjected(pProjection);
        computeDistances();
		final PointL offset = new PointL();
		getBestOffset(pProjection, offset);
		mSegmentClipper.init();
		clipAndStore(pProjection, offset, false, pStorePoints, mSegmentClipper);
		mSegmentClipper.end();
	}
368476
def plot_sphere(ax, center, radius, color='black', alpha=1., linspace_count=_LINSPACE_COUNT):
    

    u = np.linspace(0, 2 * np.pi, linspace_count)
    v = np.linspace(0, np.pi, linspace_count)
    sin_v = np.sin(v)
    x = center[0] + radius * np.outer(np.cos(u), sin_v)
    y = center[1] + radius * np.outer(np.sin(u), sin_v)
    z = center[2] + radius * np.outer(np.ones_like(u), np.cos(v))

    ax.plot_surface(x, y, z, linewidth=0.0, color=color, alpha=alpha)
967455
def warp_image_by_corner_points_projection(corner_points, image):
    
    # Clarify by storing in named variables.
    top_left, top_right, bottom_left, bottom_right = np.array(corner_points)

    top_edge = np.linalg.norm(top_right - top_left)
    bottom_edge = np.linalg.norm(bottom_right - bottom_left)
    left_edge = np.linalg.norm(top_left - bottom_left)
    right_edge = np.linalg.norm(top_right - bottom_right)

    L = int(np.ceil(max([top_edge, bottom_edge, left_edge, right_edge])))
    src = np.array([top_left, top_right, bottom_left, bottom_right])
    dst = np.array([[0, 0], [L - 1, 0], [0, L - 1], [L - 1, L - 1]])

    tr = ProjectiveTransform()
    tr.estimate(dst, src)
    warped_image = warp(image, tr, output_shape=(L, L))
    out = resize(warped_image, (500, 500))

    return out
517792
def gnomonicImageToSphere(x, y):
    
    # Convert angle to [-180, 180] interval
    x = x - 360.*(x>180)
    x = np.asarray(x)
    y = np.asarray(y)
    lon = np.degrees(np.arctan2(y, x))
    r_theta = np.sqrt(x**2 + y**2)
    lat = np.degrees(np.arctan(180. / (np.pi * r_theta)))
    return lon, lat
333866
def _get_affine_transform(self):
        """"""
        # How big is the projected globe?
        # In the case of a stereonet, it's actually constant.
        xscale = yscale = self._scale
        # Create an affine transform to stretch the projection from 0-1
        return Affine2D() \
            .rotate(np.radians(self.rotation)) \
            .scale(0.5 / xscale, 0.5 / yscale) \
            .translate(0.5, 0.5)
1138161
def project_onto(objs, axis, min_gap_size=4.0):
    
    if axis == "x":
        axis = 0
    if axis == "y":
        axis = 1
    axis_end = axis + 2
    if axis == 0:  # if projecting onto X axis
        objs.sort(key=lambda o: o.x0)
    else:
        objs.sort(key=lambda o: o.y0)

    intervals = []
    groups = []

    start_i = 0
    start = objs[0].bbox[axis]
    end = objs[0].bbox[axis_end]

    # Use _inf_bbox to trigger the last interval divide
    for o_i, o in enumerate(chain(objs, [_inf_bbox])):

        # Get current interval
        o_start = o.bbox[axis]
        o_end = o.bbox[axis_end]

        # start new interval when gap with previous end is big
        if o_start > end + min_gap_size:

            # Append new interval coordinates for children
            intervals.append((start, end))

            # Append child object group on page
            groups.append(objs[start_i:o_i])

            # Mark next obj list range
            start_i = o_i
            start = o_start

        # Always check to extend current interval to new end
        if o_end > end:
            end = o_end
        # else do nothing
    return intervals, groups
553881
def projection_to_raster_coords(self, lat, lon):
        
        r_px_py = np.array([1, lon, lat])
        tg = inv(np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]]))
        return np.inner(tg, r_px_py)[1:]
1335915
def ang2pix(nside, theta, phi):
    
    """
    nside, theta, phi = numpy.lib.stride_tricks.broadcast_arrays(nside, theta, phi)

    def equatorial(nside, tt, z):
        t1 = nside * (0.5 + tt)
        t2 = nside * z * 0.75
        jp = (t1 - t2).astype('i8')
        jm = (t1 + t2).astype('i8')
        ir = nside + 1 + jp - jm # in {1, 2n + 1}
        kshift = 1 - (ir & 1) # kshift=1 if ir even, 0 odd

        ip = (jp + jm - nside + kshift + 1) // 2 # in {0, 4n - 1}

        ip = ip % (4 * nside)
        return nside * (nside - 1) * 2 + (ir - 1) * 4 * nside + ip

    def polecaps(nside, tt, z, s):
        tp = tt - numpy.floor(tt)
        za = numpy.abs(z)
        tmp = nside * s / ((1 + za) / 3) ** 0.5
        mp = za > 0.99
        tmp[mp] = nside[mp] * (3 *(1-za[mp])) ** 0.5
        jp = (tp * tmp).astype('i8')
        jm = ((1 - tp) * tmp).astype('i8')
        ir = jp + jm + 1
        ip = (tt * ir).astype('i8')
        ip = ip % (4 * ir)

        r1 = 2 * ir * (ir - 1)
        r2 = 2 * ir * (ir + 1)

        r = numpy.empty_like(r1)

        r[z > 0] = r1[z > 0] + ip[z > 0]
        r[z < 0] = 12 * nside[z < 0] * nside[z < 0] - r2[z < 0] + ip[z < 0]
        return r

    z = numpy.cos(theta)
    s = numpy.sin(theta)

    tt = (phi / (0.5 * numpy.pi) ) % 4 # in [0, 4]

    result = numpy.zeros(z.shape, dtype='i8')
    mask = (z < 2. / 3) & (z > -2. / 3)

    result[mask] = equatorial(nside[mask], tt[mask], z[mask])
    result[~mask] = polecaps(nside[~mask], tt[~mask], z[~mask], s[~mask])
    return result