Score a view for how well it could be a seed based on the the 3 best 3D motions associated with it
484672
private SeedInfo score( View target ) {
		SeedInfo output = new SeedInfo();
		output.seed = target;
		scoresMotions.reset();

		// score all edges
		for (int i = 0; i < target.connections.size; i++) {
			PairwiseImageGraph2.Motion m = target.connections.get(i);
			if( !m.is3D )
				continue;

			scoresMotions.grow().set(score(m),i);
		}

		// only score the 3 best. This is to avoid biasing it for
		Collections.sort(scoresMotions.toList());

		for (int i = Math.min(2, scoresMotions.size); i >= 0; i--) {
			output.motions.add(scoresMotions.get(i).index);
			output.score += scoresMotions.get(i).score;
		}

		return output;
	}
84398
@SuppressWarnings({"fallthrough"})
	public static void spooky4(final long[] triple, final long seed, final long[] tuple) {
		long h0, h1, h2, h3;
		h0 = seed;
		h1 = ARBITRARY_BITS + triple[0];
		h2 = ARBITRARY_BITS + triple[1];
		h3 = ARBITRARY_BITS + triple[2];

		h2 = Long.rotateLeft(h2, 50);
		h2 += h3;
		h0 ^= h2;
		h3 = Long.rotateLeft(h3, 52);
		h3 += h0;
		h1 ^= h3;
		h0 = Long.rotateLeft(h0, 30);
		h0 += h1;
		h2 ^= h0;
		h1 = Long.rotateLeft(h1, 41);
		h1 += h2;
		h3 ^= h1;
		h2 = Long.rotateLeft(h2, 54);
		h2 += h3;
		h0 ^= h2;
		h3 = Long.rotateLeft(h3, 48);
		h3 += h0;
		h1 ^= h3;
		h0 = Long.rotateLeft(h0, 38);
		h0 += h1;
		h2 ^= h0;
		h1 = Long.rotateLeft(h1, 37);
		h1 += h2;
		h3 ^= h1;
		h2 = Long.rotateLeft(h2, 62);
		h2 += h3;
		h0 ^= h2;
		h3 = Long.rotateLeft(h3, 34);
		h3 += h0;
		h1 ^= h3;
		h0 = Long.rotateLeft(h0, 5);
		h0 += h1;
		h2 ^= h0;
		h1 = Long.rotateLeft(h1, 36);
		h1 += h2;
		h3 ^= h1;

		switch (tuple.length) {
		case 4:
			tuple[3] = h3;
		case 3:
			tuple[2] = h2;
		case 2:
			tuple[1] = h1;
		case 1:
			tuple[0] = h0;
		}
	}
163553
static double determineScale(View base , Motion edge )
		throws Exception
	{
		View viewA = edge.viewSrc;
		View viewB = edge.viewDst;

		boolean baseIsA = base == viewA;

		// determine the scale factor difference
		Point3D_F64 worldInBase3D = new Point3D_F64();
		Point3D_F64 localInBase3D = new Point3D_F64();
		GrowQueue_F64 scales = new GrowQueue_F64();
		for (int i = 0; i < edge.stereoTriangulations.size(); i++) {
			// get the feature as triangulated in this edge.
			Feature3D edge3D = edge.stereoTriangulations.get(i);

			int indexSrc = edge3D.obsIdx.get(0);
			int indexDst = edge3D.obsIdx.get(1);

			Feature3D world3D = baseIsA ? viewA.features3D[indexSrc] : viewB.features3D[indexDst];
			if( world3D == null )
				continue;
			// Find the world point in the local coordinate system
			SePointOps_F64.transformReverse(base.viewToWorld,world3D.worldPt,worldInBase3D);

			// put this point into the base frame
			if( !baseIsA ) {
				SePointOps_F64.transform(edge.a_to_b,edge3D.worldPt,localInBase3D);
			} else {
				localInBase3D.set(edge3D.worldPt);
			}

			scales.add(worldInBase3D.z / localInBase3D.z);
		}

		if( scales.size < 20 ) {
			throw new Exception("Not enough matches with known points");
		}
		// Get the scale offset as the median value to make it robust to noise
		scales.sort();
		return scales.getFraction(0.5);
	}
783417
private int[] selectBestPair( SceneStructureMetric structure ) {
		Se3_F64 w_to_0 = structure.views[0].worldToView;
		Se3_F64 w_to_1 = structure.views[1].worldToView;
		Se3_F64 w_to_2 = structure.views[2].worldToView;

		Se3_F64 view0_to_1 = w_to_0.invert(null).concat(w_to_1,null);
		Se3_F64 view0_to_2 = w_to_0.invert(null).concat(w_to_2,null);
		Se3_F64 view1_to_2 = w_to_1.invert(null).concat(w_to_2,null);

		Se3_F64 candidates[] = new Se3_F64[]{view0_to_1,view0_to_2,view1_to_2};

		int best = -1;
		double bestScore = Double.MAX_VALUE;
		for (int i = 0; i < candidates.length; i++) {
			double s = score(candidates[i]);
			System.out.println("stereo score["+i+"] = "+s);
			if( s < bestScore ) {
				bestScore = s;
				best = i;
			}
		}

		switch (best) {
			case 0: return new int[]{0,1};
			case 1: return new int[]{0,2};
			case 2: return new int[]{1,2};
		}
		throw new RuntimeException("BUG!");
	}
268004
def computePointing(self, ra_deg, dec_deg, roll_deg, cartesian=False):
        """"""
        # Roll FOV
        Rrotate = r.rotateInXMat(roll_deg)  # Roll

        # Slew from ra/dec of zero
        Ra = r.rightAscensionRotationMatrix(ra_deg)
        Rd = r.declinationRotationMatrix(dec_deg)
        Rslew = np.dot(Ra, Rd)

        R = np.dot(Rslew, Rrotate)

        slew = self.origin*1
        for i, row in enumerate(self.origin):
            slew[i, 3:6] = np.dot(R, row[3:6])

        if cartesian is False:
            slew = self.getRaDecs(slew)
        return slew
859288
public void showPointCloud(GrayF32 disparity, BufferedImage left,
							   Se3_F64 motion, DMatrixRMaj rectifiedK , DMatrixRMaj rectifiedR)
	{
		DisparityToColorPointCloud d2c = new DisparityToColorPointCloud();
		double baseline = motion.getT().norm();
		d2c.configure(baseline, rectifiedK, rectifiedR, new DoNothing2Transform2_F64(), controls.minDisparity, controls.maxDisparity);
		d2c.process(disparity,left);

		CameraPinhole rectifiedPinhole = PerspectiveOps.matrixToPinhole(rectifiedK,disparity.width,disparity.height,null);

		PointCloudViewer pcv = guiPointCloud;
		pcv.setCameraHFov(PerspectiveOps.computeHFov(rectifiedPinhole));
		pcv.setCameraToWorld(new Se3_F64());
		pcv.setTranslationStep(baseline/3);
		pcv.clearPoints();
		pcv.addCloud(d2c.getCloud(),d2c.getCloudColor());
		pcv.setDotSize(1);
		pcv.setTranslationStep(baseline/10);

		pcv.getComponent().setPreferredSize(new Dimension(left.getWidth(), left.getHeight()));

		BoofSwingUtil.invokeNowOrLater(()->{
			controls.setViews(4);
		});
	}
1020783
private void calcZDirection() {
		calcBoundaries();

		// if the longer part of the structure faces towards the back (-z direction),
		// rotate around y-axis so the longer part faces the viewer (+z direction)
		if (Math.abs(minBoundary.z) > Math.abs(maxBoundary.z)) {
			Matrix4d rot = flipY();
			rot.mul(transformationMatrix);
			transformationMatrix.set(rot);
		}
	}
245082
def draw(self):
        '''
        
        '''
        observed_arr = None
        for result_tuple in self.__feature_generator.generate():
            observed_arr = result_tuple[0]
            break

        observed_arr = observed_arr.astype(float)
        if self.__norm_mode == "z_score":
            if observed_arr.std() != 0:
                observed_arr = (observed_arr - observed_arr.mean()) / observed_arr.std()
        elif self.__norm_mode == "min_max":
            if (observed_arr.max() - observed_arr.min()) != 0:
                observed_arr = (observed_arr - observed_arr.min()) / (observed_arr.max() - observed_arr.min())
        elif self.__norm_mode == "tanh":
            observed_arr = np.tanh(observed_arr)

        return observed_arr
816930
private void doJazziness(View item, int position, int scrollDirection) {
        if (mIsScrolling) {
            if (mOnlyAnimateNewItems && mAlreadyAnimatedItems.contains(position))
                return;

            if (mOnlyAnimateOnFling && !mIsFlingEvent)
                return;

            if (mMaxVelocity > MAX_VELOCITY_OFF && mMaxVelocity < mSpeed)
                return;

            if (mSimulateGridWithList) {
                ViewGroup itemRow = (ViewGroup) item;
                for (int i = 0; i < itemRow.getChildCount(); i++)
                    doJazzinessImpl(itemRow.getChildAt(i), position, scrollDirection);
            } else {
                doJazzinessImpl(item, position, scrollDirection);
            }

            mAlreadyAnimatedItems.add(position);
        }
    }
1335445
def predmean(self, xp): 
        
        out = np.empty_like(xp)
        for i in range(3):
            out[:, i] = xp[:, i] + self.delta * xp[:, i+3]  # position
            out[:, i+3] = xp[:, i+3]                      # velocity 
        return out
1020521
protected void checkNeighbors( int cx , int cy , ImageFlow.D flow , ImageFlow image , float score ) {
		for( int i = -regionRadius; i <= regionRadius; i++ ) {
			int index = image.width*(cy+i) + (cx-regionRadius);
			for( int j = -regionRadius; j <= regionRadius; j++ , index++ ) {
				float s = scores[ index ];
				ImageFlow.D f = image.data[index];
				if( s > score ) {
					f.set(flow);
					scores[index] = score;
				} else if( s == score ) {
					// Pick solution with the least motion when ambiguous
					float m0 = f.x*f.x + f.y*f.y;
					float m1 = flow.x*flow.x + flow.y*flow.y;
					if( m1 < m0 ) {
						f.set(flow);
						scores[index] = score;
					}
				}
			}
		}
	}
1224374
private void triangulateNoLocation( View target ) {

		Se3_F64 otherToTarget = new Se3_F64();

		Se3_F64 worldToTarget = target.viewToWorld.invert(null);

		for( Motion c : target.connections ) {
			boolean isSrc = c.viewSrc == target;
			View other = c.destination(target);
			if( other.state != ViewState.PROCESSED )
				continue;

			other.viewToWorld.concat(worldToTarget,otherToTarget);

			triangulationError.configure(target.camera.pinhole,other.camera.pinhole);

			for (int i = 0; i < c.associated.size(); i++) {
				AssociatedIndex a = c.associated.get(i);

				int indexTarget = isSrc ? a.src : a.dst;
				int indexOther = isSrc ? a.dst : a.src;
				if( target.features3D[indexTarget] != null || other.features3D[indexOther] != null )
					continue;

				Point2D_F64 normOther = other.observationNorm.get( indexOther );
				Point2D_F64 normTarget = target.observationNorm.get( indexTarget );

				// Skip points with poor geometry
				double angle = triangulationAngle(normOther,normTarget,otherToTarget);
				if( angle < TRIANGULATE_MIN_ANGLE )
					continue;

				Feature3D f = new Feature3D();
				if( !triangulate.triangulate(normOther,normTarget,otherToTarget,f.worldPt))
					continue;

				// must be in front of the camera
				if( f.worldPt.z <= 0 )
					continue;

				double error = triangulationError.process(normOther,normTarget,otherToTarget,f.worldPt);
				if( error > maxPixelError*maxPixelError )
					continue;

				other.viewToWorld.transform(f.worldPt,f.worldPt);
				f.views.add( target );
				f.views.add( other );
				f.obsIdx.add( indexTarget );
				f.obsIdx.add( indexOther );

				graph.features3D.add(f);
				target.features3D[indexTarget] = f;
				other.features3D[indexOther] = f;
			}
		}
	}
913082
function snapShot() {
    var doSnapShot = {};

    if (_screenAdjusted) {
      doSnapShot = _do.getScreenAdjustedEuler();
    } else {
      doSnapShot = _do.getFixedFrameEuler();
    }

    var accSnapShot = _dm.getScreenAdjustedAcceleration();
    var accGraSnapShot = _dm.getScreenAdjustedAccelerationIncludingGravity();
    var rotRateSnapShot = _dm.getScreenAdjustedRotationRate();

    var alphaToSend = 0;

    if (_orientationBase === GAME) {
      alphaToSend = doSnapShot.alpha - _calibrationValue;
      alphaToSend = (alphaToSend < 0) ? (360 - Math.abs(alphaToSend)) : alphaToSend;
    } else {
      alphaToSend = doSnapShot.alpha;
    }

    var snapShot = {
      do: {
        alpha: rnd(alphaToSend),
        beta: rnd(doSnapShot.beta),
        gamma: rnd(doSnapShot.gamma),
        absolute: _do.isAbsolute()
      },
      dm: {
        x: rnd(accSnapShot.x),
        y: rnd(accSnapShot.y),
        z: rnd(accSnapShot.z),
        gx: rnd(accGraSnapShot.x),
        gy: rnd(accGraSnapShot.y),
        gz: rnd(accGraSnapShot.z),
        alpha: rnd(rotRateSnapShot.alpha),
        beta: rnd(rotRateSnapShot.beta),
        gamma: rnd(rotRateSnapShot.gamma)
      }
    };

    // Normalize gravity
    if (_gravityNormalized) {
      snapShot.dm.gx *= _gravityCoefficient;
      snapShot.dm.gy *= _gravityCoefficient;
      snapShot.dm.gz *= _gravityCoefficient;
    }

    return snapShot;
  }
312569
def _random_best_expander(fringe, iteration, viewer):
    '''
    
    '''
    current = fringe[0]
    neighbors = current.expand(local_search=True)
    if viewer:
        viewer.event('expanded', [current], [neighbors])

    betters = [n for n in neighbors
               if n.value > current.value]
    if betters:
        chosen = random.choice(betters)
        if viewer:
            viewer.event('chosen_node', chosen)
        fringe.append(chosen)
720015
function getter_THREE_Scene(inst) {
	return [
		inst.name,
		inst.up,
		inst.position,
		inst.quaternion,
		inst.scale,
		inst.rotationAutoUpdate,
		inst.matrix,
		inst.matrixWorld,
		inst.matrixAutoUpdate,
		inst.visible,
		inst.castShadow,
		inst.receiveShadow,
		inst.frustumCulled,
		inst.renderOrder,
		inst.userData,
		inst.children,
		inst.fog,
		inst.overrideMaterial];
}
439534
function() {
    var numStars = 2000;
    var geometry = new THREE.BufferGeometry();
    var positions = new Float32Array( numStars * 3 );
    var radius = this.STAGE_SIZE - 1;
    var v = new THREE.Vector3();
    for (var i = 0; i < positions.length; i += 3) {
      v.set(this.random(i + 23) - 0.5, this.random(i + 24), this.random(i + 25) - 0.5);
      v.normalize();
      v.multiplyScalar(radius);
      positions[i  ] = v.x;
      positions[i+1] = v.y;
      positions[i+2] = v.z;
    }
    geometry.addAttribute('position', new THREE.BufferAttribute(positions, 3));
    geometry.setDrawRange(0, 0); // don't draw any yet
    var material = new THREE.PointsMaterial({size: 0.01, color: 0xCCCCCC, fog: false});
    this.stars.setObject3D('mesh', new THREE.Points(geometry, material));
  }
900544
private boolean shouldAnimate() {
        if (!mAnimationEnabled) {
            return false;
        }
        Display display = currentDisplay();
        if (display == null) {
            return false;
        }
        if (mVisibleStartTime <= 0) {
            return false;
        }
        long threshold = (long) (1000 / display.getRefreshRate());
        long millisVisible = elapsedRealtime() - mVisibleStartTime;
        return millisVisible > threshold;
    }