當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript geom.prod3函數代碼示例

本文整理匯總了TypeScript中neuroglancer/util/geom.prod3函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript prod3函數的具體用法?TypeScript prod3怎麽用?TypeScript prod3使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了prod3函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: decodeRawChunk

export function decodeRawChunk(chunk: VolumeChunk, response: ArrayBuffer) {
  let {spec} = chunk.source!;
  let {dataType} = spec;
  let numElements = prod3(chunk.chunkDataSize!);
  let bytesPerElement = DATA_TYPE_BYTES[dataType];
  let expectedBytes = numElements * bytesPerElement * spec.numChannels;
  if (expectedBytes !== response.byteLength) {
    throw new Error(
        `Raw-format chunk is ${response.byteLength} bytes, but ${numElements} * ${bytesPerElement} = ${expectedBytes} bytes are expected.`);
  }
  let data: ArrayBufferView;
  switch (dataType) {
    case DataType.UINT8:
      data = new Uint8Array(response);
      break;
    case DataType.UINT16:
      data = new Uint16Array(response);
      break;
    case DataType.UINT32:
    case DataType.UINT64:
      data = new Uint32Array(response);
      break;
    case DataType.FLOAT32:
      data = new Float32Array(response);
      break;
    default:
      throw new Error(`Unexpected data type: ${dataType}.`);
  }
  postProcessRawData(chunk, data);
}
開發者ID:funkey,項目名稱:neuroglancer,代碼行數:30,代碼來源:raw.ts

示例2: constructor

  constructor(options: VolumeChunkSpecificationOptions) {
    let {
      lowerVoxelBound = kZeroVec,
      upperVoxelBound,
      chunkDataSize,
      voxelSize,
      transform,
      baseVoxelOffset = kZeroVec
    } = options;
    let {
      lowerClipBound = vec3.multiply(vec3.create(), voxelSize, lowerVoxelBound),
      upperClipBound = vec3.multiply(vec3.create(), voxelSize, upperVoxelBound)
    } = options;
    const chunkSize = vec3.multiply(vec3.create(), chunkDataSize, voxelSize);
    let lowerChunkBound = vec3.create();
    let upperChunkBound = vec3.create();
    for (let i = 0; i < 3; ++i) {
      lowerChunkBound[i] = Math.floor(lowerVoxelBound[i] / chunkDataSize[i]);
      upperChunkBound[i] = Math.floor((upperVoxelBound[i] - 1) / chunkDataSize[i] + 1);
    }
    super({voxelSize, transform, lowerChunkBound, upperChunkBound, chunkSize});
    this.baseVoxelOffset = baseVoxelOffset;
    this.lowerClipBound = lowerClipBound;
    this.upperClipBound = upperClipBound;
    this.lowerVoxelBound = lowerVoxelBound;
    this.upperVoxelBound = upperVoxelBound;
    this.chunkDataSize = chunkDataSize;

    let dataType = this.dataType = options.dataType;
    let numChannels = this.numChannels = options.numChannels;

    this.chunkBytes = prod3(chunkDataSize) * DATA_TYPE_BYTES[dataType] * numChannels;

    this.compressedSegmentationBlockSize = options.compressedSegmentationBlockSize;
  }
開發者ID:google,項目名稱:neuroglancer,代碼行數:35,代碼來源:base.ts

示例3: it

 it(`round trip ${volumeSize.join(',')}`, () => {
   const numPossibleValues = 15;
   const input = makeRandomUint32Array(prod3(volumeSize), numPossibleValues);
   const blockSize = [2, 2, 2];
   const output = new Uint32ArrayBuilder();
   encodeChannel(output, blockSize, input, volumeSize);
   const decoded = new Uint32Array(input.length);
   decodeChannel(decoded, output.view, 0, volumeSize, blockSize);
   expect(decoded).toEqual(input);
 });
開發者ID:j6k4m8,項目名稱:neuroglancer,代碼行數:10,代碼來源:encode_uint32.spec.ts

示例4: formatBoundingBoxVolume

export function formatBoundingBoxVolume(pointA: vec3, pointB: vec3, transform: mat4) {
  let dimensionText = '';
  const vector = vec3.create();
  for (let axis = 0; axis < 3; ++axis) {
    vec3.set(vector, 0, 0, 0);
    vector[axis] = pointB[axis] - pointA[axis];
    const spatialVector = transformVectorByMat4(vector, vector, transform);
    const length = vec3.length(spatialVector);
    if (axis !== 0) {
      dimensionText += ' × ';
    }
    dimensionText += formatLength(length);
  }

  const preTransformVolume = Math.abs(prod3(vec3.subtract(vector, pointB, pointA)));
  const det = mat3.determinant(mat3.fromMat4(mat3.create(), transform));
  const postTransformVolume = det * preTransformVolume;

  return `${dimensionText}  [${formatVolume(postTransformVolume)}]`;
}
開發者ID:google,項目名稱:neuroglancer,代碼行數:20,代碼來源:spatial_units.ts


注:本文中的neuroglancer/util/geom.prod3函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。