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


TypeScript polygons.polygonPrefixes類代碼示例

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


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

示例1: getSymmetry

export function getSymmetry(name: string): Symmetry {
  const type = getType(name);
  if (type === 'Platonic solid' || type === 'Archimedean solid') {
    const group = (() => {
      if (name.includes('tetra')) {
        return 'T';
      }
      if (name.includes('cub') || name.includes('oct')) {
        return 'O';
      }
      if (name.includes('icos') || name.includes('dodec')) {
        return 'I';
      }
      throw new Error('group not found');
    })();
    const chiral = name.includes('snub');
    return { group, sub: chiral ? '' : 'h' };
  }
  if (type === 'Prism') {
    const n = polygonPrefixes.of(name.split(' ')[0]);
    return { group: 'D', sub: `${n}h` };
  }
  if (type === 'Antiprism') {
    const n = polygonPrefixes.of(name.split(' ')[0]);
    return { group: 'D', sub: `${n}d` };
  }
  return getJohnsonSymmetry(unescapeName(name));
}
開發者ID:tessenate,項目名稱:polyhedra-viewer,代碼行數:28,代碼來源:symmetry.ts

示例2: getSymmetryName

export function getSymmetryName({ group, sub }: Symmetry) {
  if ('TOI'.includes(group)) {
    const prefix = sub === 'h' ? 'full' : 'chiral';
    const base = (() => {
      switch (group) {
        case 'T':
          return 'tetrahedral';
        case 'O':
          return 'octahedral';
        case 'I':
          return 'icosahedral';
        default:
          return '';
      }
    })();
    return `${prefix} ${base}`;
  }
  if (group === 'C') {
    if (sub === 's') {
      return 'bilateral';
    }
    if (sub === '2v') {
      return 'biradial';
    }
    const n = parseInt(_.trimEnd(sub, 'v'), 10);
    return polygonPrefixes.get(n) + ' pyramidal';
  }
  if (group === 'D') {
    const last = sub.substr(sub.length - 1);
    if (last === 'h') {
      const n = parseInt(_.trimEnd(sub, 'h'), 10);
      return polygonPrefixes.get(n) + ' prismatic';
    }
    if (last === 'd') {
      const n = parseInt(_.trimEnd(sub, 'd'), 10);
      return polygonPrefixes.get(n) + ' antiprismatic';
    }

    const n = parseInt(sub, 10);
    return polygonPrefixes.get(n) + ' dihedral';
  }
  throw new Error('invalid group');
}
開發者ID:tessenate,項目名稱:polyhedra-viewer,代碼行數:43,代碼來源:symmetry.ts

示例3:

const getPyramidCupolaConway = (name: string) => {
  const [sides, type] = name.split(' ');
  return `${pyramidCupolaConway[type]}${polygonPrefixes.of(sides)}`;
};
開發者ID:tessenate,項目名稱:polyhedra-viewer,代碼行數:4,代碼來源:operationGraph.ts


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