@thi.ng/geom
Version:
Functional, polymorphic API for 2D geometry types & SVG generation
81 lines • 2.8 kB
TypeScript
import type { Edge } from "@thi.ng/adjacency";
import type { GroupAttribs, ITessellation } from "./api.js";
import { Group } from "./api/group.js";
/**
* Creates a group of polygons from the given tessellation. If `attribs` are
* given, they will be used as the group's attribs.
*
* @remarks
* Also see:
*
* - [ITessellation](https://docs.thi.ng/umbrella/geom-tessellate/interfaces/ITessellation.html)
* - {@link edgesFromTessellation}
* - {@link edgePointsFromTessellation}
* - {@link graphFromTessellation}
*
* @param tess
* @param attribs
*/
export declare const groupFromTessellation: (tess: ITessellation, attribs?: GroupAttribs) => Group;
/**
* Create a directed or undirected graph from the given tessellation. The graph
* is stored as
* [`AdjacencyBitMatrix`](https://docs.thi.ng/umbrella/adjacency/classes/AdjacencyBitMatrix.html)
* and can be edited, queried, and analyzed further.
*
* @remarks
* Also see:
*
* - [ITessellation](https://docs.thi.ng/umbrella/geom-tessellate/interfaces/ITessellation.html)
* - {@link edgesFromTessellation}
* - {@link edgePointsFromTessellation}
* - {@link groupFromTessellation}
*
* @param tessel
*/
export declare const graphFromTessellation: ({ points, faces }: ITessellation, directed?: boolean) => import("@thi.ng/adjacency").AdjacencyBitMatrix;
/**
* Returns an iterable of unique edges in the given tessellation, where each
* edge is a 2-tuple of point indices `[a,b]`, each referring to points in the
* tessellation's `points` array.
*
* @remarks
* Also see:
*
* - [ITessellation](https://docs.thi.ng/umbrella/geom-tessellate/interfaces/ITessellation.html)
* - {@link edgePointsFromTessellation}
* - {@link graphFromTessellation}
* - {@link groupFromTessellation}
*
* @example
* ```ts
* import * as g from "@thi.ng/geom";
*
* // tessellate rect into a triangle fan
* const tess = g.tessellate(g.rect(100), [g.TESSELLATE_TRI_FAN]);
*
* // extract unique edges (ignoring direction)
* console.log([...g.edgesFromTessellation(tess)]);
* // [[ 3, 4 ], [ 2, 3 ], [ 2, 4 ], [ 1, 2 ],
* // [ 1, 4 ], [ 0, 1 ], [ 0, 3 ], [ 0, 4 ]]
* ```
*
* @param tess
*/
export declare const edgesFromTessellation: (tess: ITessellation) => Generator<Edge, void, unknown>;
/**
* Similar to {@link edgesFromTessellation}, but returns edges as pairs of
* points (instead of point IDs).
*
* @remarks
* Also see:
*
* - [ITessellation](https://docs.thi.ng/umbrella/geom-tessellate/interfaces/ITessellation.html)
* - {@link edgesFromTessellation}
* - {@link graphFromTessellation}
* - {@link groupFromTessellation}
*
* @param tess
*/
export declare const edgePointsFromTessellation: (tess: ITessellation) => IterableIterator<import("@thi.ng/vectors").ReadonlyVec[]>;
//# sourceMappingURL=from-tessellation.d.ts.map