本文整理汇总了TypeScript中math/polyhedra.Polyhedron.getVertex方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Polyhedron.getVertex方法的具体用法?TypeScript Polyhedron.getVertex怎么用?TypeScript Polyhedron.getVertex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math/polyhedra.Polyhedron
的用法示例。
在下文中一共展示了Polyhedron.getVertex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: duplicateVertices
function duplicateVertices(polyhedron: Polyhedron) {
const mapping: NestedRecord<number, number, number> = {};
const count = polyhedron.getVertex().adjacentFaces().length;
_.forEach(polyhedron.vertices, v => {
_.forEach(v.adjacentFaces(), (face, i) => {
_.set(mapping, [face.index, v.index], i);
});
});
return polyhedron.withChanges(solid => {
return solid
.withVertices(_.flatMap(polyhedron.vertices, v => repeat(v.value, count)))
.mapFaces(face => {
return _.flatMap(face.vertices, v => {
const base = count * v.index;
const j = mapping[face.index][v.index];
return [base + ((j + 1) % count), base + j];
});
})
.addFaces(
_.map(polyhedron.vertices, v =>
_.range(v.index * count, (v.index + 1) * count),
),
);
});
}
示例2: duplicateVertices
/**
* Duplicate the vertices, so that each face has its own unique set of vertices,
* and create a new face for each edge and new vertex set.
*/
function duplicateVertices(polyhedron: Polyhedron, twist?: Twist) {
const count = polyhedron.getVertex().adjacentFaces().length;
const newVertexMapping: NestedRecord<number, number, number> = {};
_.forEach(polyhedron.vertices, (v, vIndex: number) => {
// For each vertex, pick one adjacent face to be the "head"
// for every other adjacent face, map it to a duplicated vertex
_.forEach(v.adjacentFaces(), (f, i) => {
_.set(newVertexMapping, [f.index, v.index], v.index * count + i);
});
});
return polyhedron.withChanges(solid =>
solid
.withVertices(_.flatMap(polyhedron.vertices, v => repeat(v.value, count)))
.mapFaces(face =>
face.vertices.map(v => newVertexMapping[face.index][v.index]),
)
// Add a new face for each original vertex
.addFaces(
_.map(polyhedron.vertices, v =>
_.range(v.index * count, (v.index + 1) * count),
),
)
// Add a new face for each original edge
.addFaces(
_.flatMap(polyhedron.edges, edge =>
_.map(getEdgeFacePaths(edge, twist), face =>
_.map(face, path => _.get(newVertexMapping, path)),
),
),
),
);
}
示例3: expansionType
export function expansionType(polyhedron: Polyhedron): ExpansionType {
return polyhedron.getVertex().adjacentFaceCounts()[3] >= 3
? 'snub'
: 'cantellate';
}