Skip to content

Commit

Permalink
refactor(geom): update imports
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Sep 10, 2021
1 parent 85e2d4b commit 5ef5559
Show file tree
Hide file tree
Showing 71 changed files with 391 additions and 337 deletions.
6 changes: 4 additions & 2 deletions packages/geom/src/api/aabb.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { isNumber } from "@thi.ng/checks";
import { isNumber } from "@thi.ng/checks/is-number";
import type { AABBLike, Attribs } from "@thi.ng/geom-api";
import { add3, set, Vec } from "@thi.ng/vectors";
import type { Vec } from "@thi.ng/vectors";
import { add3 } from "@thi.ng/vectors/add";
import { set } from "@thi.ng/vectors/set";
import { copyAttribs } from "../internal/copy-attribs";

export class AABB implements AABBLike {
Expand Down
5 changes: 3 additions & 2 deletions packages/geom/src/api/arc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import type {
import {
pointAt as arcPointAt,
pointAtTheta as arcPointAtTheta,
} from "@thi.ng/geom-arc";
import { set, Vec } from "@thi.ng/vectors";
} from "@thi.ng/geom-arc/point-at";
import type { Vec } from "@thi.ng/vectors";
import { set } from "@thi.ng/vectors/set";
import { copyAttribs } from "../internal/copy-attribs";

export class Arc implements IHiccupShape, IHiccupPathSegment {
Expand Down
3 changes: 2 additions & 1 deletion packages/geom/src/api/circle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
import { set, Vec } from "@thi.ng/vectors";
import type { Vec } from "@thi.ng/vectors";
import { set } from "@thi.ng/vectors/set";
import { copyAttribs } from "../internal/copy-attribs";

export class Circle implements IHiccupShape {
Expand Down
5 changes: 3 additions & 2 deletions packages/geom/src/api/ellipse.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isNumber } from "@thi.ng/checks";
import { isNumber } from "@thi.ng/checks/is-number";
import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
import { set, Vec } from "@thi.ng/vectors";
import type { Vec } from "@thi.ng/vectors";
import { set } from "@thi.ng/vectors/set";
import { copyAttribs } from "../internal/copy-attribs";

export class Ellipse implements IHiccupShape {
Expand Down
4 changes: 2 additions & 2 deletions packages/geom/src/api/path.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { equiv } from "@thi.ng/equiv";
import { illegalState } from "@thi.ng/errors";
import { illegalState } from "@thi.ng/errors/illegal-state";
import type { Attribs, IHiccupShape, PathSegment } from "@thi.ng/geom-api";
import { copy } from "@thi.ng/vectors";
import { copy } from "@thi.ng/vectors/copy";
import { copyAttribs } from "../internal/copy-attribs";

export class Path implements IHiccupShape {
Expand Down
3 changes: 2 additions & 1 deletion packages/geom/src/api/plane.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
import { set, Vec } from "@thi.ng/vectors";
import type { Vec } from "@thi.ng/vectors";
import { set } from "@thi.ng/vectors/set";
import { copyAttribs } from "../internal/copy-attribs";

export class Plane implements IHiccupShape {
Expand Down
4 changes: 3 additions & 1 deletion packages/geom/src/api/ray.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
import { maddN2, set, Vec } from "@thi.ng/vectors";
import type { Vec } from "@thi.ng/vectors";
import { maddN2 } from "@thi.ng/vectors/maddn";
import { set } from "@thi.ng/vectors/set";
import { copyAttribs } from "../internal/copy-attribs";

export class Ray implements IHiccupShape {
Expand Down
10 changes: 6 additions & 4 deletions packages/geom/src/api/rect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { isNumber } from "@thi.ng/checks";
import { isNumber } from "@thi.ng/checks/is-number";
import type { AABBLike, Attribs, IHiccupShape } from "@thi.ng/geom-api";
import { add2, set, Vec } from "@thi.ng/vectors";
import type { Vec } from "@thi.ng/vectors";
import { add2 } from "@thi.ng/vectors/add";
import { set2 } from "@thi.ng/vectors/set";
import { copyAttribs } from "../internal/copy-attribs";

export class Rect implements AABBLike, IHiccupShape {
Expand All @@ -20,8 +22,8 @@ export class Rect implements AABBLike, IHiccupShape {

copy(): Rect {
return new Rect(
set([], this.pos),
set([], this.size),
set2([], this.pos),
set2([], this.size),
copyAttribs(this)
);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/geom/src/api/sphere.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
import { set3, Vec } from "@thi.ng/vectors";
import type { Vec } from "@thi.ng/vectors";
import { set3 } from "@thi.ng/vectors/set";
import { copyAttribs } from "../internal/copy-attribs";

export class Sphere implements IHiccupShape {
Expand Down
3 changes: 2 additions & 1 deletion packages/geom/src/api/text.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
import { set, Vec } from "@thi.ng/vectors";
import type { Vec } from "@thi.ng/vectors";
import { set } from "@thi.ng/vectors/set";
import { copyAttribs } from "../internal/copy-attribs";

/**
Expand Down
18 changes: 7 additions & 11 deletions packages/geom/src/ctors/aabb.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import type { Attribs } from "@thi.ng/geom-api";
import { SQRT2_2 } from "@thi.ng/math";
import {
add3,
max3,
min3,
ReadonlyVec,
sub3,
subN3,
Vec,
ZERO3,
} from "@thi.ng/vectors";
import { SQRT2_2 } from "@thi.ng/math/api";
import { add3 } from "@thi.ng/vectors/add";
import { ReadonlyVec, Vec, ZERO3 } from "@thi.ng/vectors/api";
import { max3 } from "@thi.ng/vectors/max";
import { min3 } from "@thi.ng/vectors/min";
import { sub3 } from "@thi.ng/vectors/sub";
import { subN3 } from "@thi.ng/vectors/subn";
import { AABB } from "../api/aabb";
import type { Sphere } from "../api/sphere";
import { argsVV } from "../internal/args";
Expand Down
4 changes: 2 additions & 2 deletions packages/geom/src/ctors/arc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isNumber } from "@thi.ng/checks";
import { isNumber } from "@thi.ng/checks/is-number";
import type { Attribs } from "@thi.ng/geom-api";
import { fromEndPoints } from "@thi.ng/geom-arc";
import { fromEndPoints } from "@thi.ng/geom-arc/from-endpoints";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import { Arc } from "../api/arc";

Expand Down
6 changes: 4 additions & 2 deletions packages/geom/src/ctors/circle.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Attribs } from "@thi.ng/geom-api";
import { circumCenter2 } from "@thi.ng/geom-poly-utils";
import { dist, mixN2, ReadonlyVec, Vec } from "@thi.ng/vectors";
import { circumCenter2 } from "@thi.ng/geom-poly-utils/circumcenter";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import { dist } from "@thi.ng/vectors/dist";
import { mixN2 } from "@thi.ng/vectors/mixn";
import { Circle } from "../api/circle";
import { argsVN } from "../internal/args";

Expand Down
8 changes: 3 additions & 5 deletions packages/geom/src/ctors/cubic.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { Attribs } from "@thi.ng/geom-api";
import {
cubicFromArc as _arc,
cubicFromLine as _line,
cubicFromQuadratic as _quad,
} from "@thi.ng/geom-splines";
import { cubicFromArc as _arc } from "@thi.ng/geom-splines/cubic-arc";
import { cubicFromLine as _line } from "@thi.ng/geom-splines/cubic-line";
import { cubicFromQuadratic as _quad } from "@thi.ng/geom-splines/cubic-quadratic";
import type { Vec } from "@thi.ng/vectors";
import type { Arc } from "../api/arc";
import { Cubic } from "../api/cubic";
Expand Down
2 changes: 1 addition & 1 deletion packages/geom/src/ctors/line.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Attribs } from "@thi.ng/geom-api";
import { liangBarsky2 } from "@thi.ng/geom-clip-line";
import { liangBarsky2 } from "@thi.ng/geom-clip-line/liang-barsky";
import type { Vec, VecPair } from "@thi.ng/vectors";
import { Line } from "../api/line";
import { Rect } from "../api/rect";
Expand Down
12 changes: 9 additions & 3 deletions packages/geom/src/ctors/path-builder.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { peek } from "@thi.ng/arrays";
import { peek } from "@thi.ng/arrays/peek";
import type { Attribs } from "@thi.ng/geom-api";
import { eqDelta } from "@thi.ng/math";
import { add2, copy, mulN2, set2, sub2, Vec, zeroes } from "@thi.ng/vectors";
import { eqDelta } from "@thi.ng/math/eqdelta";
import type { Vec } from "@thi.ng/vectors";
import { add2 } from "@thi.ng/vectors/add";
import { copy } from "@thi.ng/vectors/copy";
import { mulN2 } from "@thi.ng/vectors/muln";
import { set2 } from "@thi.ng/vectors/set";
import { zeroes } from "@thi.ng/vectors/setn";
import { sub2 } from "@thi.ng/vectors/sub";
import { Cubic } from "../api/cubic";
import { Line } from "../api/line";
import { Path } from "../api/path";
Expand Down
6 changes: 3 additions & 3 deletions packages/geom/src/ctors/path-from-svg.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IObjectOf } from "@thi.ng/api";
import { illegalState } from "@thi.ng/errors";
import { rad } from "@thi.ng/math";
import { WS } from "@thi.ng/strings";
import { illegalState } from "@thi.ng/errors/illegal-state";
import { rad } from "@thi.ng/math/angle";
import { WS } from "@thi.ng/strings/groups";
import type { Vec } from "@thi.ng/vectors";
import { PathBuilder } from "./path-builder";

Expand Down
8 changes: 5 additions & 3 deletions packages/geom/src/ctors/path.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { isNumber } from "@thi.ng/checks";
import { isNumber } from "@thi.ng/checks/is-number";
import type { Attribs, PathSegment } from "@thi.ng/geom-api";
import { map, mapcat } from "@thi.ng/transducers";
import { maddN2, Vec } from "@thi.ng/vectors";
import { map } from "@thi.ng/transducers/xform/map";
import { mapcat } from "@thi.ng/transducers/xform/mapcat";
import type { Vec } from "@thi.ng/vectors";
import { maddN2 } from "@thi.ng/vectors/maddn";
import type { Cubic } from "../api/cubic";
import { Path } from "../api/path";
import { asCubic } from "../ops/as-cubic";
Expand Down
11 changes: 4 additions & 7 deletions packages/geom/src/ctors/plane.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import type { Attribs } from "@thi.ng/geom-api";
import {
dot3,
normalize,
orthoNormal3,
ReadonlyVec,
Vec,
} from "@thi.ng/vectors";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import { dot3 } from "@thi.ng/vectors/dot";
import { normalize } from "@thi.ng/vectors/normalize";
import { orthoNormal3 } from "@thi.ng/vectors/ortho-normal";
import { Plane } from "../api/plane";

export const plane = (normal: Vec, w: number, attribs?: Attribs) =>
Expand Down
19 changes: 9 additions & 10 deletions packages/geom/src/ctors/polygon.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { Attribs } from "@thi.ng/geom-api";
import { TAU } from "@thi.ng/math";
import {
cycle,
map,
normRange,
push,
transduce,
zip,
} from "@thi.ng/transducers";
import { cartesian2, Vec } from "@thi.ng/vectors";
import { TAU } from "@thi.ng/math/api";
import { cycle } from "@thi.ng/transducers/iter/cycle";
import { normRange } from "@thi.ng/transducers/iter/norm-range";
import { zip } from "@thi.ng/transducers/iter/zip";
import { push } from "@thi.ng/transducers/rfn/push";
import { transduce } from "@thi.ng/transducers/transduce";
import { map } from "@thi.ng/transducers/xform/map";
import type { Vec } from "@thi.ng/vectors";
import { cartesian2 } from "@thi.ng/vectors/cartesian";
import { Polygon } from "../api/polygon";

export const polygon = (pts: Vec[], attribs?: Attribs) =>
Expand Down
10 changes: 6 additions & 4 deletions packages/geom/src/ctors/quad.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { isNumber } from "@thi.ng/checks";
import { isNumber } from "@thi.ng/checks/is-number";
import type { Attribs } from "@thi.ng/geom-api";
import { closestPointPlane } from "@thi.ng/geom-closest-point";
import { alignmentQuat, mulVQ } from "@thi.ng/matrices";
import { add3, ReadonlyVec, Vec, Z3 } from "@thi.ng/vectors";
import { closestPointPlane } from "@thi.ng/geom-closest-point/plane";
import { alignmentQuat } from "@thi.ng/matrices/alignment-quat";
import { mulVQ } from "@thi.ng/matrices/mulv";
import { add3 } from "@thi.ng/vectors/add";
import { ReadonlyVec, Vec, Z3 } from "@thi.ng/vectors/api";
import type { Plane } from "../api/plane";
import { Quad } from "../api/quad";
import { Quad3 } from "../api/quad3";
Expand Down
6 changes: 3 additions & 3 deletions packages/geom/src/ctors/quadratic.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { quadraticFromLine as _line } from "@thi.ng/geom-splines";
import { Quadratic } from "../api/quadratic";
import { pclike } from "../internal/pclike";
import type { Attribs } from "@thi.ng/geom-api";
import { quadraticFromLine as _line } from "@thi.ng/geom-splines/quadratic-line";
import type { Vec } from "@thi.ng/vectors";
import { Quadratic } from "../api/quadratic";
import { pclike } from "../internal/pclike";

export function quadratic(a: Vec, b: Vec, c: Vec, attribs?: Attribs): Quadratic;
export function quadratic(pts: Vec[], attribs?: Attribs): Quadratic;
Expand Down
5 changes: 3 additions & 2 deletions packages/geom/src/ctors/ray.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { normalize as _norm, Vec } from "@thi.ng/vectors";
import { Ray } from "../api/ray";
import type { Attribs } from "@thi.ng/geom-api";
import type { Vec } from "@thi.ng/vectors";
import { normalize as _norm } from "@thi.ng/vectors/normalize";
import { Ray } from "../api/ray";

export const ray = (pos: Vec, dir: Vec, attribs?: Attribs, normalize = true) =>
new Ray(pos, normalize ? _norm(null, dir) : dir, attribs);
24 changes: 10 additions & 14 deletions packages/geom/src/ctors/rect.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import type { Attribs } from "@thi.ng/geom-api";
import { centroid } from "@thi.ng/geom-poly-utils";
import { SQRT2_2, SQRT3 } from "@thi.ng/math";
import {
add2,
dist,
maddN2,
max2,
min2,
ReadonlyVec,
sub2,
subN2,
Vec,
ZERO2,
} from "@thi.ng/vectors";
import { centroid } from "@thi.ng/geom-poly-utils/centroid";
import { SQRT2_2, SQRT3 } from "@thi.ng/math/api";
import { add2 } from "@thi.ng/vectors/add";
import { ReadonlyVec, Vec, ZERO2 } from "@thi.ng/vectors/api";
import { dist } from "@thi.ng/vectors/dist";
import { maddN2 } from "@thi.ng/vectors/maddn";
import { max2 } from "@thi.ng/vectors/max";
import { min2 } from "@thi.ng/vectors/min";
import { sub2 } from "@thi.ng/vectors/sub";
import { subN2 } from "@thi.ng/vectors/subn";
import type { Circle } from "../api/circle";
import type { Polygon } from "../api/polygon";
import { Rect } from "../api/rect";
Expand Down
6 changes: 4 additions & 2 deletions packages/geom/src/ctors/sphere.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { dist, mixN3, ReadonlyVec, Vec } from "@thi.ng/vectors";
import type { Attribs } from "@thi.ng/geom-api";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import { dist } from "@thi.ng/vectors/dist";
import { mixN3 } from "@thi.ng/vectors/mixn";
import { Sphere } from "../api/sphere";
import { argsVN } from "../internal/args";
import type { Attribs } from "@thi.ng/geom-api";

export function sphere(pos: Vec, r: number, attribs?: Attribs): Sphere;
export function sphere(pos: Vec, attribs?: Attribs): Sphere;
Expand Down
6 changes: 3 additions & 3 deletions packages/geom/src/ctors/triangle.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { equilateralTriangle2 } from "@thi.ng/geom-poly-utils";
import { Triangle } from "../api/triangle";
import { pclike } from "../internal/pclike";
import type { Attribs } from "@thi.ng/geom-api";
import { equilateralTriangle2 } from "@thi.ng/geom-poly-utils/equilateral";
import type { Vec } from "@thi.ng/vectors";
import { Triangle } from "../api/triangle";
import { pclike } from "../internal/pclike";

export function triangle(a: Vec, b: Vec, c: Vec, attribs?: Attribs): Triangle;
export function triangle(pts: Vec[], attribs?: Attribs): Triangle;
Expand Down
5 changes: 3 additions & 2 deletions packages/geom/src/internal/args.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { peek } from "@thi.ng/arrays";
import { isNumber, isPlainObject } from "@thi.ng/checks";
import { peek } from "@thi.ng/arrays/peek";
import { isNumber } from "@thi.ng/checks/is-number";
import { isPlainObject } from "@thi.ng/checks/is-plain-object";

/**
* Takes an array of arguments, checks if last element is a plain object
Expand Down
2 changes: 1 addition & 1 deletion packages/geom/src/internal/coll-bounds.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mixCubic as _mixCubic } from "@thi.ng/math";
import { mixCubic as _mixCubic } from "@thi.ng/math/mix";
import { unionBounds } from "./union-bounds";
import type { Fn } from "@thi.ng/api";
import type { AABBLike, IShape } from "@thi.ng/geom-api";
Expand Down
2 changes: 1 addition & 1 deletion packages/geom/src/internal/copy-shape.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { copyVectors } from "@thi.ng/vectors";
import { copyVectors } from "@thi.ng/vectors/copy";
import { copyAttribs } from "./copy-attribs";
import type { PCLike, PCLikeConstructor } from "@thi.ng/geom-api";

Expand Down
3 changes: 2 additions & 1 deletion packages/geom/src/internal/edges.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { partition, wrapSides } from "@thi.ng/transducers";
import { wrapSides } from "@thi.ng/transducers/iter/wrap-sides";
import { partition } from "@thi.ng/transducers/xform/partition";
import type { ReadonlyVec, VecPair } from "@thi.ng/vectors";

export const edgeIterator = (vertices: Iterable<ReadonlyVec>, closed = false) =>
Expand Down
5 changes: 3 additions & 2 deletions packages/geom/src/internal/points-as-shape.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { map } from "@thi.ng/transducers";
import { copyVectors, Vec } from "@thi.ng/vectors";
import type { Attribs, PCLikeConstructor } from "@thi.ng/geom-api";
import { map } from "@thi.ng/transducers/xform/map";
import type { Vec } from "@thi.ng/vectors";
import { copyVectors } from "@thi.ng/vectors/copy";

export const pointArraysAsShapes = (
ctor: PCLikeConstructor,
Expand Down
4 changes: 3 additions & 1 deletion packages/geom/src/internal/split.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { mixN, set, Vec, VecPair } from "@thi.ng/vectors";
import type { Vec, VecPair } from "@thi.ng/vectors";
import { mixN } from "@thi.ng/vectors/mixn";
import { set } from "@thi.ng/vectors/set";

export const splitLine = (a: Vec, b: Vec, t: number): [VecPair, VecPair] => {
const p = mixN([], a, b, t);
Expand Down
Loading

0 comments on commit 5ef5559

Please sign in to comment.