本文整理匯總了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)}`;
};