Skip to content

Commit

Permalink
docs(geom): add/update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed May 5, 2024
1 parent d10bf43 commit 74ce227
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/geom/src/centroid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import { bounds } from "./bounds.js";
import { __dispatch } from "./internal/dispatch.js";

/**
* Computes centroid of given shape, writes result in optionally provided output
* vector (or creates new one if omitted).
* Computes (possibly weighted) centroid of given shape, writes result in
* optionally provided output vector (or creates new one if omitted).
*
* @remarks
* Currently implemented for:
Expand All @@ -35,6 +35,7 @@ import { __dispatch } from "./internal/dispatch.js";
* - {@link Arc}
* - {@link BPatch}
* - {@link Circle}
* - {@link ComplexPolygon}
* - {@link Cubic}
* - {@link Ellipse}
* - {@link Group}
Expand Down
7 changes: 5 additions & 2 deletions packages/geom/src/classify-point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ import { __dispatch } from "./internal/dispatch.js";
* Currently only implemented for:
*
* - {@link Circle}
* - {@link Plane}
* - {@link Plane} (-1 = below, +1 = above)
* - {@link Sphere}
* - {@link Triangle}
*
* The [thi.ng/geom-sdf](https://thi.ng/thi.ng/geom-sdf) package provides a much
* more comprehensive feature set (incl. support for more shapes) to perform
* similar checks as this function.
*
* Also see {@link pointInside}.
* Also see:
* - {@link closestPoint}
* - {@link pointInside}
* - {@link proximity}
*
* @param shape
* @param p
Expand Down
18 changes: 18 additions & 0 deletions packages/geom/src/complex-polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ import type { Attribs } from "@thi.ng/geom-api";
import { ComplexPolygon } from "./api/complex-polygon.js";
import { Polygon } from "./api/polygon.js";

/**
* Creates a {@link ComplexPolygon} instance from given `boundary` and `child`
* polygons (the latter are assumed non-overlapping holes and will be
* interpreted as such).
*
* @remarks
* Child polygons are considered holes and fully enclosed by the boundary poly.
* Depending on usage, holes should also have the opposite vertex order (e.g.
* via {@link flip}) than the boundary. This is not enforced automatically and
* the user's responsibility.
*
* Any attribs on `boundary` or `children` will be ignored, only those given as
* `attribs` will be used.
*
* @param boundary
* @param children
* @param attribs
*/
export const complexPolygon = (
boundary?: Polygon,
children?: Iterable<Polygon>,
Expand Down
3 changes: 2 additions & 1 deletion packages/geom/src/simplify.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Maybe } from "@thi.ng/api";
import { peek } from "@thi.ng/arrays/peek";
import type { MultiFn1O } from "@thi.ng/defmulti";
import { defmulti } from "@thi.ng/defmulti/defmulti";
Expand Down Expand Up @@ -35,7 +36,7 @@ import { vertices } from "./vertices.js";
*/
export const simplify: MultiFn1O<IShape, number, IShape> = defmulti<
any,
number | undefined,
Maybe<number>,
IShape
>(
__dispatch,
Expand Down

0 comments on commit 74ce227

Please sign in to comment.