Skip to content

Commit

Permalink
perf(geom): update vector fns
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Aug 6, 2022
1 parent f3dcda8 commit d8726c9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/geom/src/plane.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import type { Attribs } from "@thi.ng/geom-api";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import { dot3 } from "@thi.ng/vectors/dot";
import { normalize } from "@thi.ng/vectors/normalize";
import { normalize3 } from "@thi.ng/vectors/normalize";
import { orthoNormal3 } from "@thi.ng/vectors/ortho-normal";
import { Plane } from "./api/plane.js";

export const plane = (normal: Vec, w: number, attribs?: Attribs) =>
new Plane(normalize(null, normal), w, attribs);
new Plane(normalize3(null, normal), w, attribs);

export const planeWithPoint = (
normal: Vec,
p: ReadonlyVec,
attribs?: Attribs
) => {
normal = normalize(null, normal);
normal = normalize3(null, normal);
return new Plane(normal, dot3(normal, p), attribs);
};

Expand Down
4 changes: 2 additions & 2 deletions packages/geom/src/scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { IHiccupShape, IShape } from "@thi.ng/geom-api";
import type { ReadonlyVec } from "@thi.ng/vectors";
import { mul2, mul3 } from "@thi.ng/vectors/mul";
import { mulN2, mulN3 } from "@thi.ng/vectors/muln";
import { normalize } from "@thi.ng/vectors/normalize";
import { normalize2 } from "@thi.ng/vectors/normalize";
import { AABB } from "./api/aabb.js";
import type { Arc } from "./api/arc.js";
import { Circle } from "./api/circle.js";
Expand Down Expand Up @@ -150,7 +150,7 @@ export const scale: MultiFn2<IShape, number | ReadonlyVec, IShape> = defmulti<
delta = __asVec(delta);
return new Ray(
mul2([], $.pos, delta),
normalize(null, mul2([], $.dir, delta)),
normalize2(null, mul2([], $.dir, delta)),
__copyAttribs($)
);
},
Expand Down
4 changes: 2 additions & 2 deletions packages/geom/src/tangent-at.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { quadraticTangentAt } from "@thi.ng/geom-splines/quadratic-tangent";
import { cossin } from "@thi.ng/math/angle";
import { HALF_PI, TAU } from "@thi.ng/math/api";
import type { Vec } from "@thi.ng/vectors";
import { direction } from "@thi.ng/vectors/direction";
import { direction2 } from "@thi.ng/vectors/direction";
import type { Cubic } from "./api/cubic.js";
import type { Line } from "./api/line.js";
import type { Rect } from "./api/rect.js";
Expand Down Expand Up @@ -49,7 +49,7 @@ export const tangentAt: MultiFn2<IShape, number, Vec | undefined> = defmulti<
cubic: ({ points }: Cubic, t) =>
cubicTangentAt([], points[0], points[1], points[2], points[3], t),

line: ({ points }: Line) => direction([], points[0], points[1]),
line: ({ points }: Line) => direction2([], points[0], points[1]),

poly: ($: PCLike, t) => new Sampler($.points, true).tangentAt(t),

Expand Down

0 comments on commit d8726c9

Please sign in to comment.