本文整理汇总了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;未经允许,请勿转载。 |
请发表评论