Sample random camera position.
  
  Sample origin directed camera position in given distance
  range from the origin. ModelView matrix is returned.
509114
def sample_view(min_dist, max_dist=None):
  '''
  '''
  if max_dist is None:
    max_dist = min_dist
  dist = np.random.uniform(min_dist, max_dist)
  eye = np.random.normal(size=3)
  eye = normalize(eye)*dist
  return lookat(eye)
1028362
def _generate_relative_positions_matrix(length_q, length_k,
                                        max_relative_position,
                                        cache=False):
  """"""
  if not cache:
    if length_q == length_k:
      range_vec_q = range_vec_k = tf.range(length_q)
    else:
      range_vec_k = tf.range(length_k)
      range_vec_q = range_vec_k[-length_q:]
    distance_mat = range_vec_k[None, :] - range_vec_q[:, None]
  else:
    distance_mat = tf.expand_dims(tf.range(-length_k+1, 1, 1), 0)
  distance_mat_clipped = tf.clip_by_value(distance_mat, -max_relative_position,
                                          max_relative_position)
  # Shift values to be >= 0. Each integer still uniquely identifies a relative
  # position difference.
  final_mat = distance_mat_clipped + max_relative_position
  return final_mat
1065017
def generateDistanceMatrix(width, height):
	
	
	# Determine the coordinates of the exact centre of the window
	originX = width / 2
	originY = height / 2
	
	# Generate the distance matrix
	distances = zerosFactory((height,width), dtype=np.float)
	for index, val in np.ndenumerate(distances):
		y,x = index
		distances[(y,x)] = math.sqrt( math.pow(x - originX, 2) + math.pow(y - originY, 2) )
	
	return distances
1097819
def sample_to_frame_range(self, sample_index):
        
        start = max(0, int((sample_index - self.frame_size) / self.hop_size) + 1)
        end = int(sample_index / self.hop_size) + 1
        return start, end
819488
function () {
            var result = {};

            var queryString = window.location.href.split("?");
            if (queryString && queryString.length > 1) {
                var args = queryString[1].split("&");

                for (var a = 0; a < args.length; a++) {
                    var arg = args[a].split("=");

                    // Obtain geographic position to redirect WorldWindow camera view.
                    if (arg[0] === "pos") {
                        // arg format is "pos=lat,lon,alt"
                        var position = arg[1].split(","),
                            lat = parseFloat(position[0]),
                            lon = parseFloat(position[1]),
                            alt = parseFloat(position[2]);
                        result.position = new WorldWind.Position(lat, lon, alt);
                    }
                }
            }

            return result;
        }
609234
void computeRawDescriptor(double c_x, double c_y, double sigma, double orientation, TupleDesc_F64 descriptor) {
		double c = Math.cos(orientation);
		double s = Math.sin(orientation);

		float fwidthSubregion = widthSubregion;
		int sampleWidth = widthGrid*widthSubregion;
		double sampleRadius = sampleWidth/2;

		double sampleToPixels = sigma*sigmaToPixels;

		Deriv image = (Deriv)imageDerivX.getImage();

		for (int sampleY = 0; sampleY < sampleWidth; sampleY++) {
			float subY = sampleY/fwidthSubregion;
			double y = sampleToPixels*(sampleY-sampleRadius);

			for (int sampleX = 0; sampleX < sampleWidth; sampleX++) {
				// coordinate of samples in terms of sub-region.  Center of sample point, hence + 0.5f
				float subX = sampleX/fwidthSubregion;
				// recentered local pixel sample coordinate
				double x = sampleToPixels*(sampleX-sampleRadius);

				// pixel coordinate in the image that is to be sampled.  Note the rounding
				// If the pixel coordinate is -1 < x < 0 then it will round to 0 instead of -1, but the rounding
				// method below is WAY faster than Math.round() so this is a small loss.
				int pixelX = (int)(x*c - y*s + c_x + 0.5);
				int pixelY = (int)(x*s + y*c + c_y + 0.5);

				// skip pixels outside of the image
				if( image.isInBounds(pixelX,pixelY) ) {
					// spacial image derivative at this point
					float spacialDX = imageDerivX.unsafe_getF(pixelX, pixelY);
					float spacialDY = imageDerivY.unsafe_getF(pixelX, pixelY);

					double adjDX =  c*spacialDX + s*spacialDY;
					double adjDY = -s*spacialDX + c*spacialDY;

					double angle = UtilAngle.domain2PI(Math.atan2(adjDY,adjDX));

					float weightGaussian = gaussianWeight[sampleY*sampleWidth+sampleX];
					float weightGradient = (float)Math.sqrt(spacialDX*spacialDX + spacialDY*spacialDY);

					// trilinear interpolation intro descriptor
					trilinearInterpolation(weightGaussian*weightGradient,subX,subY,angle, descriptor);
				}
			}
		}
	}
236064
def __generate_location(self):
        
        screen_width = world.get_backbuffer_size().X
        self.movement_speed = random.randrange(10, 25)

        # This line of code places the cloud to the right of the viewable screen, so it appears to
        # gradually move in from the right instead of randomally appearing on some portion of the viewable
        # window.
        self.coords = R.Vector2(screen_width + self.image.get_width(), random.randrange(0, 100))
110418
def sample_id(self, lon):
        ''' 

        '''
        if self.grid == 'WAC':
            sample = np.rint(float(self.SAMPLE_PROJECTION_OFFSET) + 1.0 +
                             (lon * np.pi / 180.0 - float(self.CENTER_LONGITUDE)) *
                             self.A_AXIS_RADIUS *
                             np.cos(self.CENTER_LATITUDE * np.pi / 180.0)
                             / (self.MAP_SCALE * 1e-3))
        else:
            sample = np.rint(float(self.SAMPLE_PROJECTION_OFFSET) + float(self.MAP_RESOLUTION)
                             * (lon - float(self.CENTER_LONGITUDE))) + 1
        return self._control_sample(sample)
692898
def pixel(self, coord_x, coord_y):
        # type: (int, int) -> Pixel
        

        try:
            return self.pixels[coord_y][coord_x]  # type: ignore
        except IndexError:
            raise ScreenShotError(
                "Pixel location ({}, {}) is out of range.".format(coord_x, coord_y)
            )
519200
def undistortPoints(self, points, keepSize=False):
        '''
        
        '''
        s = self.img.shape
        cam = self.coeffs['cameraMatrix']
        d = self.coeffs['distortionCoeffs']

        pts = np.asarray(points, dtype=np.float32)
        if pts.ndim == 2:
            pts = np.expand_dims(pts, axis=0)

        (newCameraMatrix, roi) = cv2.getOptimalNewCameraMatrix(cam,
                                                               d, s[::-1], 1,
                                                               s[::-1])
        if not keepSize:
            xx, yy = roi[:2]
            pts[0, 0] -= xx
            pts[0, 1] -= yy

        return cv2.undistortPoints(pts,
                                   cam, d, P=newCameraMatrix)
826864
public void convertIntoBundleStructure(List<Se3_F64> motions,
										   DMatrixRMaj K,
										   double[] distort,
										   List<CalibrationObservation> obs ) {

		structure = new SceneStructureMetric(false);
		observations = new SceneObservations(motions.size(),true);

		structure.initialize(1,motions.size(),layout.size(),1);

		// A single camera is assumed, that's what is being calibrated!
		structure.setCamera(0,false,cameraGenerator.initalizeCamera(K,distort));
		// A single rigid planar target is being viewed. It is assumed to be centered at the origin
		structure.setRigid(0,true,new Se3_F64(),layout.size());
		// Where the points are on the calibration target
		SceneStructureMetric.Rigid rigid = structure.rigids[0];
		for (int i = 0; i < layout.size(); i++) {
			rigid.setPoint(i,layout.get(i).x,layout.get(i).y,0);
		}

		// Add the initial estimate of each view's location and the points observed
		for (int viewIdx = 0; viewIdx < motions.size(); viewIdx++) {
			structure.setView(viewIdx,false,motions.get(viewIdx));
			SceneObservations.View v = observations.getViewRigid(viewIdx);
			structure.connectViewToCamera(viewIdx,0);
			CalibrationObservation ca = obs.get(viewIdx);
			for (int j = 0; j < ca.size(); j++) {
				PointIndex2D_F64 p = ca.get(j);
				v.add(p.index, (float)p.x, (float)p.y);
				structure.connectPointToView(p.index,viewIdx);
			}
		}
	}
1336876
def offset(self, index=0):
        """"""
        eta = self._geometry[self.camera][index]["ra"]
        xi = self._geometry[self.camera][index]["dec"]
        ra = self.origin.ra - (eta/math.cos(self.dec.radian))*units.degree
        dec = self.origin.dec - xi * units.degree + 45 * units.arcsec
        self._coordinate = SkyCoord(ra, dec)
782531
function calculateMatrixAndOffset({
  // UNCHANGED
  viewport,
  // NEW PARAMS
  coordinateSystem,
  coordinateOrigin,
  coordinateZoom
}) {
  const {viewMatrixUncentered} = viewport;
  let {viewMatrix} = viewport;
  const {projectionMatrix} = viewport;
  let {viewProjectionMatrix} = viewport;

  let projectionCenter;
  let cameraPos = viewport.cameraPosition;
  let shaderCoordinateSystem = getShaderCoordinateSystem(coordinateSystem);
  let shaderCoordinateOrigin = coordinateOrigin;

  if (shaderCoordinateSystem === PROJECT_COORDINATE_SYSTEM.LNGLAT_AUTO_OFFSET) {
    if (coordinateZoom < LNGLAT_AUTO_OFFSET_ZOOM_THRESHOLD) {
      // Use LNG_LAT projection if not zooming
      shaderCoordinateSystem = PROJECT_COORDINATE_SYSTEM.LNG_LAT;
    } else {
      // Use LNGLAT_AUTO_OFFSET
      const lng = Math.fround(viewport.longitude);
      const lat = Math.fround(viewport.latitude);
      shaderCoordinateOrigin = [lng, lat];
    }
  }

  switch (shaderCoordinateSystem) {
    case PROJECT_COORDINATE_SYSTEM.IDENTITY:
    case PROJECT_COORDINATE_SYSTEM.LNG_LAT:
      projectionCenter = ZERO_VECTOR;
      break;

    // TODO: make lighting work for meter offset mode
    case PROJECT_COORDINATE_SYSTEM.LNGLAT_OFFSETS:
    case PROJECT_COORDINATE_SYSTEM.METER_OFFSETS:
    case PROJECT_COORDINATE_SYSTEM.LNGLAT_AUTO_OFFSET:
      // Calculate transformed projectionCenter (using 64 bit precision JS)
      // This is the key to offset mode precision
      // (avoids doing this addition in 32 bit precision in GLSL)
      const positionPixels = viewport.projectFlat(
        shaderCoordinateOrigin,
        Math.pow(2, coordinateZoom)
      );

      cameraPos = [
        cameraPos[0] - positionPixels[0],
        cameraPos[1] - positionPixels[1],
        cameraPos[2]
      ];

      // projectionCenter = new Matrix4(viewProjectionMatrix)
      //   .transformVector([positionPixels[0], positionPixels[1], 0.0, 1.0]);
      projectionCenter = vec4.transformMat4(
        [],
        [positionPixels[0], positionPixels[1], 0.0, 1.0],
        viewProjectionMatrix
      );

      // Always apply uncentered projection matrix if available (shader adds center)
      viewMatrix = viewMatrixUncentered || viewMatrix;

      // Zero out 4th coordinate ("after" model matrix) - avoids further translations
      // viewMatrix = new Matrix4(viewMatrixUncentered || viewMatrix)
      //   .multiplyRight(VECTOR_TO_POINT_MATRIX);
      viewProjectionMatrix = mat4.multiply([], projectionMatrix, viewMatrix);
      viewProjectionMatrix = mat4.multiply([], viewProjectionMatrix, VECTOR_TO_POINT_MATRIX);
      break;

    default:
      throw new Error('Unknown projection mode');
  }

  return {
    viewMatrix,
    viewProjectionMatrix,
    projectionCenter,
    cameraPos,
    shaderCoordinateSystem,
    shaderCoordinateOrigin
  };
}
1022350
function (renderer, camera) {
        var viewport = renderer.viewport;
        var dpr = viewport.devicePixelRatio || renderer.getDevicePixelRatio();
        var width = viewport.width * dpr;
        var height = viewport.height * dpr;

        var offset = this._haltonSequence[this._frame % this._haltonSequence.length];

        var translationMat = new Matrix4();
        translationMat.array[12] = (offset[0] * 2.0 - 1.0) / width;
        translationMat.array[13] = (offset[1] * 2.0 - 1.0) / height;

        Matrix4.mul(camera.projectionMatrix, translationMat, camera.projectionMatrix);

        Matrix4.invert(camera.invProjectionMatrix, camera.projectionMatrix);
    }
802745
private void ar2gvr(float[] poseMatrix, float scale) {
        // Real world scale
        Matrix.scaleM(poseMatrix, 0, scale, scale, scale);
        poseMatrix[12] = poseMatrix[12] * scale;
        poseMatrix[13] = poseMatrix[13] * scale;
        poseMatrix[14] = poseMatrix[14] * scale;
    }
1115873
def view_isometric(self):
        
        self.camera_position = self.get_default_cam_pos()
        self.camera_set = False
        return self.reset_camera()
333238
public void setCamera1( double fx , double fy , double skew , double cx , double cy ) {
		PerspectiveOps.pinholeToMatrix(fx,fy,skew,cx,cy,K1);
	}