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