Skip to content

Commit

Permalink
refactor(vectors): cleanup, update docs/readme
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Oct 2, 2020
1 parent 6e78a2b commit 142515f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 52 deletions.
15 changes: 8 additions & 7 deletions packages/vectors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ yarn add @thi.ng/vectors
<script src="https://unpkg.com/@thi.ng/vectors/lib/index.umd.js" crossorigin></script>
```

Package sizes (gzipped, pre-treeshake): ESM: 11.15 KB / CJS: 14.03 KB / UMD: 12.40 KB
Package sizes (gzipped, pre-treeshake): ESM: 11.19 KB / CJS: 14.08 KB / UMD: 12.43 KB

## Dependencies

Expand Down Expand Up @@ -446,12 +446,13 @@ Component wise op with one input vector and single scalar:

### Distances

| Function | Generic | Fixed | Strided | Int | Comments |
|-----------------|---------|-------|---------|-----|----------|
| `dist` || | | | |
| `distSq` || 2-4 | | | |
| `distChebyshev` || 2-4 | | | |
| `distManhattan` || 2-4 | | | |
| Function | Generic | Fixed | Strided | Int | Comments |
|-----------------|---------|-------|---------|-----|-------------------|
| `dist` || | | | |
| `distSq` || 2-4 | | | |
| `distChebyshev` || 2-4 | | | |
| `distManhattan` || 2-4 | | | |
| `pointOnRay` || 2-3 | | | point at distance |

### Orientation

Expand Down
2 changes: 1 addition & 1 deletion packages/vectors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export * from "./normalizes";
export * from "./not";
export * from "./ortho-normal";
export * from "./perpendicular";
export * from "./point-on-ray";
export * from "./polar";
export * from "./point-at";
export * from "./pow";
export * from "./pown";
export * from "./project";
Expand Down
38 changes: 0 additions & 38 deletions packages/vectors/src/point-at.ts

This file was deleted.

48 changes: 48 additions & 0 deletions packages/vectors/src/point-on-ray.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Vec } from "./api";
import { maddN, maddN2, maddN3 } from "./maddn";

/**
* Calculates the nD point laying on ray at given distance. `rayDir` MUST be
* normalized.
*
* @param out -
* @param rayOrigin -
* @param rayDir -
* @param dist -
*/
export const pointOnRay = (
out: Vec | null,
rayOrigin: Vec,
rayDir: Vec,
dist: number
) => maddN(out, rayDir, dist, rayOrigin);

/**
* 2D version of {@link pointOnRay}.
*
* @param out -
* @param rayOrigin -
* @param rayDir -
* @param dist -
*/
export const pointOnRay2 = (
out: Vec | null,
rayOrigin: Vec,
rayDir: Vec,
dist: number
) => maddN2(out, rayDir, dist, rayOrigin);

/**
* 3D version of {@link pointOnRay}.
*
* @param out -
* @param rayOrigin -
* @param rayDir -
* @param dist -
*/
export const pointOnRay3 = (
out: Vec | null,
rayOrigin: Vec,
rayDir: Vec,
dist: number
) => maddN3(out, rayDir, dist, rayOrigin);
13 changes: 7 additions & 6 deletions packages/vectors/tpl.readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,13 @@ Component wise op with one input vector and single scalar:

### Distances

| Function | Generic | Fixed | Strided | Int | Comments |
|-----------------|---------|-------|---------|-----|----------|
| `dist` || | | | |
| `distSq` || 2-4 | | | |
| `distChebyshev` || 2-4 | | | |
| `distManhattan` || 2-4 | | | |
| Function | Generic | Fixed | Strided | Int | Comments |
|-----------------|---------|-------|---------|-----|-------------------|
| `dist` || | | | |
| `distSq` || 2-4 | | | |
| `distChebyshev` || 2-4 | | | |
| `distManhattan` || 2-4 | | | |
| `pointOnRay` || 2-3 | | | point at distance |

### Orientation

Expand Down

0 comments on commit 142515f

Please sign in to comment.