Vector3, Camera -> Vector3 (-1.0 to 1.0)
548702
function orthoProj_(pos, cam){
    var vec = V3.sub(pos, cam.pos);
    var camAxis = axis(cam);
    var normDist = V3.dot(vec, camAxis.y);
    var normProj = V3.scale(normDist, camAxis.y);
    var posOnPlane = V3.add(vec, V3_(-normProj.x, -normProj.y, -normProj.z));
    var x = V3.dot(posOnPlane, camAxis.x);
    var y = V3.dot(posOnPlane, camAxis.z);
    return V3_(x, y, normDist);
  }
967185
function _Vector3(x, y, z) {
  if(!x) x = 0;
  if(!y) y = 0;
  if(!z) z = 0;

  var values = [x, y, z];
  Vector.apply(this, [3, values]);

  readonly(this, "x", x);
  readonly(this, "y", y);
  readonly(this, "z", z);
  readonly(this, "homogeneous", _getHomogeneous(this));
  readonly(this, "vector4", _getVector4(this));
}
1029131
function getter_THREE_PerspectiveCamera(inst) {
	return [
		inst.fov,
		inst.aspect,
		inst.near,
		inst.far];
}
84636
def vertex_normals(vertices, faces):
    """"""

    def normalize_v3(arr):
        ''' Normalize a numpy array of 3 component vectors shape=(n,3) '''
        lens = np.sqrt(arr[:, 0]**2 + arr[:, 1]**2 + arr[:, 2]**2)
        arr /= lens[:, np.newaxis]

    tris = vertices[faces]
    facenorms = np.cross(tris[::, 1] - tris[::, 0], tris[::, 2] - tris[::, 0])
    normalize_v3(facenorms)

    norm = np.zeros(vertices.shape, dtype=vertices.dtype)
    norm[faces[:, 0]] += facenorms
    norm[faces[:, 1]] += facenorms
    norm[faces[:, 2]] += facenorms
    normalize_v3(norm)
    return norm
935222
function calculateMatrixAndOffset({
  // UNCHANGED
  viewport,
  // NEW PARAMS
  coordinateSystem,
  coordinateOrigin,
  coordinateZoom
}) {
  const {viewMatrixUncentered} = viewport;
  let {viewMatrix} = viewport;
  const {projectionMatrix} = viewport;
  let {viewProjectionMatrix} = viewport;

  let projectionCenter;
  let cameraPosCommon = 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];
    }
  }
  if (shaderCoordinateSystem === PROJECT_COORDINATE_SYSTEM.IDENTITY) {
    // We only support 64-bit precision in the X and Y components of positions for now
    shaderCoordinateOrigin = [Math.fround(viewport.position[0]), Math.fround(viewport.position[1])];
  }

  switch (shaderCoordinateSystem) {
    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:
    case PROJECT_COORDINATE_SYSTEM.IDENTITY:
      // 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 positionCommonSpace = viewport.projectPosition(
        shaderCoordinateOrigin,
        Math.pow(2, coordinateZoom)
      );

      cameraPosCommon = [
        cameraPosCommon[0] - positionCommonSpace[0],
        cameraPosCommon[1] - positionCommonSpace[1],
        cameraPosCommon[2]
      ];

      positionCommonSpace[2] = 0;
      positionCommonSpace[3] = 1;

      // projectionCenter = new Matrix4(viewProjectionMatrix)
      //   .transformVector([positionPixels[0], positionPixels[1], 0.0, 1.0]);
      projectionCenter = vec4.transformMat4([], positionCommonSpace, 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,
    cameraPosCommon,
    shaderCoordinateSystem,
    shaderCoordinateOrigin
  };
}
1107051
private void triangulateFeatures(List<AssociatedTriple> inliers,
									 DMatrixRMaj P1, DMatrixRMaj P2, DMatrixRMaj P3) {
		List<DMatrixRMaj> cameraMatrices = new ArrayList<>();
		cameraMatrices.add(P1);
		cameraMatrices.add(P2);
		cameraMatrices.add(P3);

		// need elements to be non-empty so that it can use set().  probably over optimization
		List<Point2D_F64> triangObs = new ArrayList<>();
		triangObs.add(null);
		triangObs.add(null);
		triangObs.add(null);

		Point4D_F64 X = new Point4D_F64();
		for (int i = 0; i < inliers.size(); i++) {
			AssociatedTriple t = inliers.get(i);

			triangObs.set(0,t.p1);
			triangObs.set(1,t.p2);
			triangObs.set(2,t.p3);

			// triangulation can fail if all 3 views have the same pixel value. This has been observed in
			// simulated 3D scenes
			if( triangulator.triangulate(triangObs,cameraMatrices,X)) {
				structure.points[i].set(X.x,X.y,X.z,X.w);
			} else {
				throw new RuntimeException("Failed to triangulate a point in the inlier set?! Handle if this is common");
			}
		}
	}
821111
function Vector(x, y) {
    this.x = x != null ? x : 0.0;
    this.y = y != null ? y : 0.0;
  }
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;
    }
719006
def normalize_vector(v):
    
    norm = np.linalg.norm(v)
    return v/norm if not norm == 0 else v
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;
			}
		}
	}
76382
def translate_v3(vec, amount):
    """"""

    return Vec3(vec.x+amount, vec.y+amount, vec.z+amount)
155763
def to_vec3(self):
        """"""
        vec3 = Vector3()
        vec3.x = self.x
        vec3.y = self.y
        vec3.z = self.z

        if self.w != 0:
            vec3 /= self.w

        return vec3
275734
private static double[] toVector(Point3d src, Point3d dest) {
        return new double[]{dest.x - src.x, dest.y - src.y, dest.z - src.z};
    }
1145339
def set_scale(self, xscale=None, yscale=None, zscale=None, reset_camera=True):
        
        if xscale is None:
            xscale = self.scale[0]
        if yscale is None:
            yscale = self.scale[1]
        if zscale is None:
            zscale = self.scale[2]
        self.scale = [xscale, yscale, zscale]

        # Update the camera's coordinate system
        transform = vtk.vtkTransform()
        transform.Scale(xscale, yscale, zscale)
        self.camera.SetModelTransformMatrix(transform.GetMatrix())
        self.parent._render()
        if reset_camera:
            self.update_bounds_axes()
            self.reset_camera()
95660
static Object wrapVec3(float x, float y, float z) {
        ByteBuffer temp = ByteBuffer.allocate(3 * 4);
        temp.putFloat(x);
        temp.putFloat(y);
        temp.putFloat(z);
        temp.flip();
        return s_wrapperProvider.wrapVector3f(temp, 0, 3);
    }
1143223
def make_pose(translation, rotation):
    
    pose = np.zeros((4, 4))
    pose[:3, :3] = rotation
    pose[:3, 3] = translation
    pose[3, 3] = 1.0
    return pose
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);
    }