Skip to content

Commit

Permalink
fix(geom-closest-point): flip sign of plane W component, extract dist…
Browse files Browse the repository at this point in the history
…ToPlane()
  • Loading branch information
postspectacular committed May 22, 2019
1 parent 3f085a3 commit 74dbcb0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/geom-closest-point/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ export const closestPointArray = (p: ReadonlyVec, pts: Vec[]) => {
return closest;
};

export const distToPlane = (p: ReadonlyVec, n: ReadonlyVec, w: number) =>
dot(n, p) - w;

export const closestPointPlane = (
p: ReadonlyVec,
normal: ReadonlyVec,
w: number,
out: Vec = []
) => {
out = normalize(out, normal, dot(p, normal) + w);
return sub(out, p, out);
};
) => sub(out, p, normalize(out, normal, distToPlane(p, normal, w)));

export const closestPointCircle = (
p: ReadonlyVec,
Expand Down

0 comments on commit 74dbcb0

Please sign in to comment.