本文整理汇总了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));
}
示例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');
}
示例3:
const getPyramidCupolaConway = (name: string) => {
const [sides, type] = name.split(' ');
return `${pyramidCupolaConway[type]}${polygonPrefixes.of(sides)}`;
};