Causes the camera to "orbit" around the target point.
        This is also called "tumbling" in some software packages.
779217
def orbit(self, x1_px, y1_px, x2_px, y2_px):
        
        px_per_deg = self.vport_radius_px / float(self.orbit_speed)
        radians_per_px = 1.0 / px_per_deg * np.pi / 180.0

        t2p = self.position - self.target

        M = Matrix4x4.rotation_around_origin((x1_px - x2_px) * radians_per_px,
                                             self.ground)
        t2p = M * t2p
        self.up = M * self.up

        right = (self.up ^ t2p).normalized()
        M = Matrix4x4.rotation_around_origin((y1_px - y2_px) * radians_per_px,
                                             right)
        t2p = M * t2p
        self.up = M * self.up

        self.position = self.target + t2p
1003151
boolean findRemainingCameraMatrices(LookupSimilarImages db, View seed, GrowQueue_I32 motions) {
		points3D.reset(); // points in 3D
		for (int i = 0; i < structure.points.length; i++) {
			structure.points[i].get(points3D.grow());
		}
		// contains associated pairs of pixel observations
		// save a call to db by using the previously loaded points
		assocPixel.reset();
		for (int i = 0; i < inlierToSeed.size; i++) {
			// inliers from triple RANSAC
			// each of these inliers was declared a feature in the world reference frame
			assocPixel.grow().p1.set(matchesTriple.get(i).p1);
		}

		DMatrixRMaj cameraMatrix = new DMatrixRMaj(3,4);
		for (int motionIdx = 0; motionIdx < motions.size; motionIdx++) {
			// skip views already in the scene's structure
			if( motionIdx == selectedTriple[0] || motionIdx == selectedTriple[1])
				continue;
			int connectionIdx = motions.get(motionIdx);
			Motion edge = seed.connections.get(connectionIdx);
			View viewI = edge.other(seed);

			// Lookup pixel locations of features in the connected view
			db.lookupPixelFeats(viewI.id,featsB);

			if ( !computeCameraMatrix(seed, edge,featsB,cameraMatrix) ) {
				if( verbose != null ) {
					verbose.println("Pose estimator failed! motionIdx="+motionIdx);
				}
				return false;
			}
			db.lookupShape(edge.other(seed).id,shape);
			structure.setView(motionIdx,false,cameraMatrix,shape.width,shape.height);

		}
		return true;
	}
436876
function _wheelHandler(e) {
      var pos,
          ratio,
          animation,
          wheelDelta = sigma.utils.getDelta(e);

      if (_settings('mouseEnabled') && _settings('mouseWheelEnabled') && wheelDelta !== 0) {
        ratio = wheelDelta > 0 ?
          1 / _settings('zoomingRatio') :
          _settings('zoomingRatio');

        pos = _camera.cameraPosition(
          sigma.utils.getX(e) - sigma.utils.getCenter(e).x,
          sigma.utils.getY(e) - sigma.utils.getCenter(e).y,
          true
        );

        animation = {
          duration: _settings('mouseZoomDuration')
        };

        sigma.utils.zoomTo(_camera, pos.x, pos.y, ratio, animation);

        if (e.preventDefault)
          e.preventDefault();
        else
          e.returnValue = false;

        e.stopPropagation();
        return false;
      }
    }
269346
def _offset_setup(self,sigangle,leading,deltaAngleTrack):
        """"""
        #From the progenitor orbit, determine the sigmas in J and angle
        self._sigjr= (self._progenitor.rap()-self._progenitor.rperi())/numpy.pi*self._sigv
        self._siglz= self._progenitor.rperi()*self._sigv
        self._sigjz= 2.*self._progenitor.zmax()/numpy.pi*self._sigv
        #Estimate the frequency covariance matrix from a diagonal J matrix x dOdJ
        self._sigjmatrix= numpy.diag([self._sigjr**2.,
                                      self._siglz**2.,
                                      self._sigjz**2.])
        self._sigomatrix= numpy.dot(self._dOdJp,
                                    numpy.dot(self._sigjmatrix,self._dOdJp.T))
        #Estimate angle spread as the ratio of the largest to the middle eigenvalue
        self._sigomatrixEig= numpy.linalg.eig(self._sigomatrix)
        self._sigomatrixEigsortIndx= numpy.argsort(self._sigomatrixEig[0])
        self._sortedSigOEig= sorted(self._sigomatrixEig[0])
        if sigangle is None:
            self._sigangle= self._sigv*1.8
        else:
            self._sigangle= sigangle
        self._sigangle2= self._sigangle**2.
        self._lnsigangle= numpy.log(self._sigangle)
        #Estimate the frequency mean as lying along the direction of the largest eigenvalue
        self._dsigomeanProgDirection= self._sigomatrixEig[1][:,numpy.argmax(self._sigomatrixEig[0])]
        self._progenitor_Omega_along_dOmega= \
            numpy.dot(self._progenitor_Omega,self._dsigomeanProgDirection)
        #Make sure we are modeling the correct part of the stream
        self._leading= leading
        self._sigMeanSign= 1.
        if self._leading and self._progenitor_Omega_along_dOmega < 0.:
            self._sigMeanSign= -1.
        elif not self._leading and self._progenitor_Omega_along_dOmega > 0.:
            self._sigMeanSign= -1.
        self._progenitor_Omega_along_dOmega*= self._sigMeanSign 
        self._sigomean= self._progenitor_Omega\
            +self._sigMeanOffset*self._sigMeanSign\
            *numpy.sqrt(numpy.amax(self._sigomatrixEig[0]))\
            *self._dsigomeanProgDirection
#numpy.dot(self._dOdJp,
#                          numpy.array([self._sigjr,self._siglz,self._sigjz]))
        self._dsigomeanProg= self._sigomean-self._progenitor_Omega
        self._meandO= self._sigMeanOffset\
            *numpy.sqrt(numpy.amax(self._sigomatrixEig[0]))
        #Store cholesky of sigomatrix for fast evaluation
        self._sigomatrixNorm=\
            numpy.sqrt(numpy.sum(self._sigomatrix**2.))
        self._sigomatrixinv, self._sigomatrixLogdet= \
            fast_cholesky_invert(self._sigomatrix/self._sigomatrixNorm,
                                 tiny=10.**-15.,logdet=True)
        self._sigomatrixinv/= self._sigomatrixNorm
        deltaAngleTrackLim = (self._sigMeanOffset+4.) * numpy.sqrt(
            self._sortedSigOEig[2]) * self._tdisrupt
        if (deltaAngleTrack is None):  
            deltaAngleTrack = deltaAngleTrackLim
        else:
            if (deltaAngleTrack > deltaAngleTrackLim):
                warnings.warn("WARNING: angle range large compared to plausible value.", galpyWarning)
        self._deltaAngleTrack= deltaAngleTrack
        return None
1108566
void setOrthoShadowMatrix(Matrix4f modelMtx, GVRLight light)
    {
        GVROrthogonalCamera camera = (GVROrthogonalCamera) getCamera();
        if (camera == null)
        {
            return;
        }

        float w = camera.getRightClippingDistance() - camera.getLeftClippingDistance();
        float h = camera.getTopClippingDistance() - camera.getBottomClippingDistance();
        float near = camera.getNearClippingDistance();
        float far = camera.getFarClippingDistance();

        modelMtx.invert();
        modelMtx.get(mTempMtx);
        camera.setViewMatrix(mTempMtx);
        mShadowMatrix.setOrthoSymmetric(w, h, near, far);
        mShadowMatrix.mul(modelMtx);
        sBiasMatrix.mul(mShadowMatrix, mShadowMatrix);
        mShadowMatrix.getColumn(0, mTemp);
        light.setVec4("sm0", mTemp.x, mTemp.y, mTemp.z, mTemp.w);
        mShadowMatrix.getColumn(1, mTemp);
        light.setVec4("sm1", mTemp.x, mTemp.y, mTemp.z, mTemp.w);
        mShadowMatrix.getColumn(2, mTemp);
        light.setVec4("sm2", mTemp.x, mTemp.y, mTemp.z, mTemp.w);
        mShadowMatrix.getColumn(3, mTemp);
        light.setVec4("sm3", mTemp.x, mTemp.y, mTemp.z, mTemp.w);
    }
900959
public boolean update( Image input , RectangleRotate_F64 output ) {

		if( trackLost )
			return false;

		trackFeatures(input, region);

		// See if there are enough points remaining.  use of config.numberOfSamples is some what arbitrary
		if( pairs.size() < config.numberOfSamples ) {
			System.out.println("Lack of sample pairs");
			trackLost = true;
			return false;
		}

		// find the motion using tracked features
		if( !estimateMotion.process(pairs.toList()) ) {
			System.out.println("estimate motion failed");
			trackLost = true;
			return false;
		}

		if( estimateMotion.getFitQuality() > config.robustMaxError ) {
			System.out.println("exceeded Max estimation error");
			trackLost = true;
			return false;
		}

		// update the target's location using the found motion
		ScaleTranslateRotate2D model = estimateMotion.getModelParameters();

		region.width *= model.scale;
		region.height *= model.scale;

		double c = Math.cos(model.theta);
		double s = Math.sin(model.theta);

		double x = region.cx;
		double y = region.cy;

		region.cx = (x*c - y*s)*model.scale + model.transX;
		region.cy = (x*s + y*c)*model.scale + model.transY;

		region.theta += model.theta;

		output.set(region);

		// make the current image into the previous image
		swapImages();

		return true;
	}
1330473
def clear_camera_positions(self):
        
        for action in self.saved_camera_menu.actions():
            self.saved_camera_menu.removeAction(action)
279193
public static void avoidCollision(CmsPositionBean posA, CmsPositionBean posB, int margin) {

        Direction dir = null;
        int diff = 0;
        int diffTemp = (posB.getLeft() + posB.getWidth()) - posA.getLeft();
        if (diffTemp > -margin) {
            dir = Direction.left;
            diff = diffTemp;
        }

        diffTemp = (posA.getLeft() + posA.getWidth()) - posB.getLeft();
        if ((diffTemp > -margin) && (diffTemp < diff)) {
            dir = Direction.right;
            diff = diffTemp;
        }
        diffTemp = (posB.getTop() + posB.getHeight()) - posA.getTop();
        if ((diffTemp > -margin) && (diffTemp < diff)) {
            dir = Direction.top;
            diff = diffTemp;
        }
        diffTemp = (posA.getTop() + posA.getHeight()) - posB.getTop();
        if ((diffTemp > -margin) && (diffTemp < diff)) {
            dir = Direction.bottom;
            diff = diffTemp;
        }

        diff = (int)Math.ceil((1.0 * (diff + margin)) / 2);
        if (dir != null) {
            switch (dir) {
                case left:
                    // move the left border of a
                    posA.setLeft(posA.getLeft() + diff);
                    posA.setWidth(posA.getWidth() - diff);

                    // move the right border of b
                    posB.setWidth(posB.getWidth() - diff);
                    break;

                case right:
                    // move the left border of b
                    posB.setLeft(posB.getLeft() + diff);
                    posB.setWidth(posB.getWidth() - diff);

                    // move the right border of a
                    posA.setWidth(posA.getWidth() - diff);
                    break;

                case top:
                    posA.setTop(posA.getTop() + diff);
                    posA.setHeight(posA.getHeight() - diff);

                    posB.setHeight(posB.getHeight() - diff);
                    break;
                case bottom:
                    posB.setTop(posB.getTop() + diff);
                    posB.setHeight(posB.getHeight() - diff);

                    posA.setHeight(posA.getHeight() - diff);
                    break;
                default:
                    // nothing to do
            }
        }
    }
1329154
public void attachCenterCamera(GVRPerspectiveCamera camera) {
        if (camera.hasOwnerObject()) {
            camera.getOwnerObject().detachCamera();
        }

        centerCameraObject.attachCamera(camera);
        centerCamera = camera;
        NativeCameraRig.attachCenterCamera(getNative(), camera.getNative());
    }
364882
function (x, y) {

      var t = this._currentTransform,
          o = this._offset;

      if (t.target.lockRotation) return;

      var lastAngle = atan2(t.ey - t.top - o.top, t.ex - t.left - o.left),
          curAngle = atan2(y - t.top - o.top, x - t.left - o.left);

      t.target._theta = (curAngle - lastAngle) + t.theta;
    }
996553
function() {
            this.x = this.body.p.x;
            this.y = this.body.p.y;
            this.rotation = this.body.a * RAD2DEG;
        }
594810
function(frameData) {
        var dt = frameData.dt / 1000; // Time in s
        var oldR = this._rotation,
            vr = this._vrotation,
            ar = this._arotation;

        // s += v * Δt + (0.5 * a) * Δt * Δt
        var newR = oldR + vr * dt + 0.5 * ar * dt * dt;
        // v += a * Δt
        this.vrotation = vr + ar * dt;

        // Check if direction of velocity has changed
        var _vr = this._vrotation,
            dvr = _vr ? (_vr < 0 ? -1 : 1) : 0; // Quick implementation of Math.sign
        if (this.__oldRotationDirection !== dvr) {
            this.__oldRotationDirection = dvr;
            this.trigger("NewRotationDirection", dvr);
        }

        // Check if velocity has changed
        // Δs = s[t] - s[t-1]
        this._drotation = newR - oldR;
        if (this._drotation !== 0) {
            this.rotation = newR;
            this.trigger("Rotated", oldR);
        }
    }
296381
def camera_action_raw(self, world_pos):
    """"""
    action = sc_pb.Action()
    world_pos.assign_to(action.action_raw.camera_move.center_world_space)
    return action
136421
function (newCameraEl) {
    var newCamera;
    var previousCamera = this.spectatorCameraEl;
    var sceneEl = this.sceneEl;
    var spectatorCameraEl;

    // Same camera.
    newCamera = newCameraEl.getObject3D('camera');
    if (!newCamera || newCameraEl === this.spectatorCameraEl) { return; }

    // Disable current camera
    if (previousCamera) {
      previousCamera.setAttribute('camera', 'spectator', false);
    }

    spectatorCameraEl = this.spectatorCameraEl = newCameraEl;

    sceneEl.addEventListener('enter-vr', this.wrapRender);
    sceneEl.addEventListener('exit-vr', this.unwrapRender);

    spectatorCameraEl.setAttribute('camera', 'active', false);
    spectatorCameraEl.play();

    sceneEl.emit('camera-set-spectator', {cameraEl: newCameraEl});
  }
219720
protected boolean closeCamera() {
		if( verbose )
			Log.i(TAG,"closeCamera() activity="+getClass().getSimpleName());
		if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
			throw new RuntimeException("Attempted to close camera not on the main looper thread!");
		}

		boolean closed = false;

//		if( verbose ) {
//			StackTraceElement[] trace = new RuntimeException().getStackTrace();
//			for (int i = 0; i < Math.min(trace.length, 3); i++) {
//				System.out.println("[ " + i + " ] = " + trace[i].toString());
//			}
//		}

		// NOTE: Since open can only be called in the main looper this won't be enough to prevent
		// it from closing before it opens. That's why open.state exists
		open.mLock.lock();
		try {
			if( verbose )
				Log.i(TAG,"closeCamera: camera="+(open.mCameraDevice==null)+" state="+open.state);
			closePreviewSession();
			// close has been called while trying to open the camera!
			if( open.state == CameraState.OPENING ) {
				// If it's in this state that means an asych task is opening the camera. By changing the state
				// to closing it will not abort that process when the task is called.
				open.state = CameraState.CLOSING;
				if( open.mCameraDevice != null ) {
					throw new RuntimeException("BUG! Camera is opening and should be null until opened");
				}
			} else {
				if (null != open.mCameraDevice) {
					closed = true;
					open.closeCamera();
				}
				open.state = CameraState.CLOSED;
				open.clearCamera();
			}
		} finally {
			open.mLock.unlock();
		}
		return closed;
	}
706800
private void onHotspotBoundsChanged() {
        final int count = mExitingRipplesCount;
        final RippleForeground[] ripples = mExitingRipples;
        for (int i = 0; i < count; i++) {
            ripples[i].onHotspotBoundsChanged();
        }

        if (mRipple != null) {
            mRipple.onHotspotBoundsChanged();
        }

        if (mBackground != null) {
            mBackground.onHotspotBoundsChanged();
        }
    }
459894
private void findBestValidSolution(BundleAdjustment<SceneStructureMetric> bundleAdjustment) {
		// prints out useful debugging information that lets you know how well it's converging
		if( verbose != null && verboseLevel > 0 )
			bundleAdjustment.setVerbose(verbose,0);

		// Specifies convergence criteria
		bundleAdjustment.configure(convergeSBA.ftol, convergeSBA.gtol, convergeSBA.maxIterations);

		bundleAdjustment.setParameters(structure,observations);
		bundleAdjustment.optimize(structure);

		// ensure that the points are in front of the camera and are a valid solution
		if( checkBehindCamera(structure) ) {
			if( verbose != null )
				verbose.println("  flipping view");
			flipAround(structure,observations);
			bundleAdjustment.setParameters(structure,observations);
			bundleAdjustment.optimize(structure);
		}

		double bestScore = bundleAdjustment.getFitScore();
		List<Se3_F64> bestPose = new ArrayList<>();
		List<BundlePinholeSimplified> bestCameras = new ArrayList<>();
		for (int i = 0; i < structure.views.length; i++) {
			BundlePinholeSimplified c = structure.cameras[i].getModel();
			bestPose.add(structure.views[i].worldToView.copy());
			bestCameras.add( c.copy());
		}

		for (int i = 0; i < structure.cameras.length; i++) {
			BundlePinholeSimplified c = structure.cameras[i].getModel();
			c.f = listPinhole.get(i).fx;
			c.k1 = c.k2 = 0;
		}
		// flip rotation assuming that it was done wrong
		for (int i = 1; i < structure.views.length; i++) {
			CommonOps_DDRM.transpose(structure.views[i].worldToView.R);
		}
		triangulatePoints(structure,observations);

		bundleAdjustment.setParameters(structure,observations);
		bundleAdjustment.optimize(structure);

		if( checkBehindCamera(structure) ) {
			if( verbose != null )
				verbose.println("  flipping view");
			flipAround(structure,observations);
			bundleAdjustment.setParameters(structure,observations);
			bundleAdjustment.optimize(structure);
		}

		// revert to old settings
		if( verbose != null )
			verbose.println(" ORIGINAL / NEW = " + bestScore+" / "+bundleAdjustment.getFitScore());
		if( bundleAdjustment.getFitScore() > bestScore ) {
			if( verbose != null )
				verbose.println("  recomputing old structure");
			for (int i = 0; i < structure.cameras.length; i++) {
				BundlePinholeSimplified c = structure.cameras[i].getModel();
				c.set(bestCameras.get(i));
				structure.views[i].worldToView.set(bestPose.get(i));
			}
			triangulatePoints(structure,observations);
			bundleAdjustment.setParameters(structure,observations);
			bundleAdjustment.optimize(structure);
			if( verbose != null )
				verbose.println("  score = "+bundleAdjustment.getFitScore());
		}
	}