本文整理匯總了TypeScript中math/polygons.polygonPrefixes.of方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript polygonPrefixes.of方法的具體用法?TypeScript polygonPrefixes.of怎麽用?TypeScript polygonPrefixes.of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類math/polygons.polygonPrefixes
的用法示例。
在下文中一共展示了polygonPrefixes.of方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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:
const getPyramidCupolaConway = (name: string) => {
const [sides, type] = name.split(' ');
return `${pyramidCupolaConway[type]}${polygonPrefixes.of(sides)}`;
};