Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:thi-ng/umbrella into develop
Browse files Browse the repository at this point in the history
* 'develop' of github.com:thi-ng/umbrella:
  refactor(vectors): renaming and minor fixes at point-on-ray
  feat(vectors, geom): point on ray at distance
  • Loading branch information
postspectacular committed Oct 2, 2020
2 parents b32c7eb + 1f28571 commit 6e78a2b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/geom/src/ops/point-at.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { cossin, fit01, TAU } from "@thi.ng/math";
import {
cartesian2,
madd2,
maddN,
mixCubic,
mixN2,
mixQuadratic,
pointAtOnRay,
Vec,
} from "@thi.ng/vectors";
import { Arc } from "../api/arc";
Expand Down Expand Up @@ -45,7 +45,7 @@ pointAt.addAll(<IObjectOf<Implementation2<unknown, number, Vec>>>{
[Type.QUADRATIC]: ({ points }: Quadratic, t) =>
mixQuadratic([], points[0], points[1], points[2], t),

[Type.RAY]: ($: Ray, t) => maddN([], $.dir, t, $.pos),
[Type.RAY]: ($: Ray, t) => pointAtOnRay([], $.dir, t, $.pos),

[Type.RECT]: ($: Rect, t) => new Sampler(vertices($), true).pointAt(t),
});
Expand Down
1 change: 1 addition & 0 deletions packages/vectors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export * from "./not";
export * from "./ortho-normal";
export * from "./perpendicular";
export * from "./polar";
export * from "./point-at";
export * from "./pow";
export * from "./pown";
export * from "./project";
Expand Down
38 changes: 38 additions & 0 deletions packages/vectors/src/point-at.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Vec, maddN } from ".";
import { maddN2, maddN3 } from "./maddn";

/**
* Calculates the point laying on ray at given distance
*
*
* @param out -
* @param rayDir -
* @param rayOrigin -
* @param dist -
*/
export const pointOnRay = (
out: Vec | null,
rayOrigin: Vec,
rayDir: Vec,
dist: number
) => {
return maddN(out, rayDir, dist, rayOrigin);
};

export const pointOnRay2 = (
out: Vec | null,
rayOrigin: Vec,
rayDir: Vec,
dist: number
) => {
return maddN2(out, rayDir, dist, rayOrigin);
};

export const pointOnRay3 = (
out: Vec | null,
rayOrigin: Vec,
rayDir: Vec,
dist: number
) => {
return maddN3(out, rayDir, dist, rayOrigin);
};

0 comments on commit 6e78a2b

Please sign in to comment.