Skip to content

Commit

Permalink
feat(vectors): update VecAPI & presets
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Oct 27, 2023
1 parent 4ccde2e commit 0d9f62b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/vectors/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
Tuple,
TypedArray,
} from "@thi.ng/api";
import type { IRandom } from "@thi.ng/random";

export interface Vec extends Iterable<number>, ILength {
[id: number]: number;
Expand Down Expand Up @@ -530,6 +531,7 @@ export interface VecAPI {
invSqrt: VecOpV;
mag: VecOpRoV<number>;
magSq: VecOpRoV<number>;
limit: VecOpVN;
log: VecOpV;
log2: VecOpV;
madd: VecOpVVV;
Expand All @@ -550,6 +552,11 @@ export interface VecAPI {
pow: VecOpVV;
powN: VecOpVN;
radians: VecOpV;
random: VecOpOOO<number, number, IRandom>;
randomDistrib: VecOpFNO;
randMinMax: VecOpOOO<ReadonlyVec, ReadonlyVec, IRandom>;
randNorm: (v: Vec | null, n?: number, rnd?: IRandom) => Vec;
randNormDistrib: VecOpNFO;
round: VecOpVV;
set: VecOpV;
setN: VecOpN;
Expand All @@ -563,6 +570,7 @@ export interface VecAPI {
subm: VecOpVVV;
submN: VecOpVVN;
tan: VecOpV;
trunc: VecOpV;

eq: CompareOp;
neq: CompareOp;
Expand Down
16 changes: 16 additions & 0 deletions packages/vectors/src/vec2-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { fract2 } from "./fract.js";
import { gt2 } from "./gt.js";
import { gte2 } from "./gte.js";
import { invSqrt2 } from "./invsqrt.js";
import { limit2 } from "./limit.js";
import { log2 } from "./log.js";
import { log_22 } from "./log_2.js";
import { lt2 } from "./lt.js";
Expand All @@ -53,6 +54,13 @@ import { normalize2 } from "./normalize.js";
import { pow2 } from "./pow.js";
import { powN2 } from "./pown.js";
import { radians2 } from "./radians.js";
import {
randMinMax2,
randNorm2,
randNormDistrib2,
random2,
randomDistrib2,
} from "./random.js";
import { round2 } from "./round.js";
import { set2 } from "./set.js";
import { setN2 } from "./setn.js";
Expand All @@ -66,6 +74,7 @@ import { subm2 } from "./subm.js";
import { submN2 } from "./submn.js";
import { subN2 } from "./subn.js";
import { tan2 } from "./tan.js";
import { trunc2 } from "./trunc.js";

export const VEC2: VecAPI = {
abs: abs2,
Expand Down Expand Up @@ -101,6 +110,7 @@ export const VEC2: VecAPI = {
maddN: maddN2,
mag: mag2,
magSq: magSq2,
limit: limit2,
log: log2,
log2: log_22,
major: major2,
Expand All @@ -119,6 +129,11 @@ export const VEC2: VecAPI = {
pow: pow2,
powN: powN2,
radians: radians2,
random: random2,
randomDistrib: randomDistrib2,
randMinMax: randMinMax2,
randNorm: randNorm2,
randNormDistrib: randNormDistrib2,
round: round2,
set: set2,
setN: setN2,
Expand All @@ -132,6 +147,7 @@ export const VEC2: VecAPI = {
subm: subm2,
submN: submN2,
tan: tan2,
trunc: trunc2,

eq: eq2,
neq: neq2,
Expand Down
16 changes: 16 additions & 0 deletions packages/vectors/src/vec3-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { fract3 } from "./fract.js";
import { gt3 } from "./gt.js";
import { gte3 } from "./gte.js";
import { invSqrt3 } from "./invsqrt.js";
import { limit3 } from "./limit.js";
import { log3 } from "./log.js";
import { log_23 } from "./log_2.js";
import { lt3 } from "./lt.js";
Expand All @@ -53,6 +54,13 @@ import { normalize3 } from "./normalize.js";
import { pow3 } from "./pow.js";
import { powN3 } from "./pown.js";
import { radians3 } from "./radians.js";
import {
randMinMax3,
randNorm3,
randNormDistrib3,
random3,
randomDistrib3,
} from "./random.js";
import { round3 } from "./round.js";
import { set3 } from "./set.js";
import { setN3 } from "./setn.js";
Expand All @@ -66,6 +74,7 @@ import { subm3 } from "./subm.js";
import { submN3 } from "./submn.js";
import { subN3 } from "./subn.js";
import { tan3 } from "./tan.js";
import { trunc3 } from "./trunc.js";

export const VEC3: VecAPI = {
abs: abs3,
Expand Down Expand Up @@ -101,6 +110,7 @@ export const VEC3: VecAPI = {
maddN: maddN3,
mag: mag3,
magSq: magSq3,
limit: limit3,
log: log3,
log2: log_23,
major: major3,
Expand All @@ -119,6 +129,11 @@ export const VEC3: VecAPI = {
pow: pow3,
powN: powN3,
radians: radians3,
random: random3,
randomDistrib: randomDistrib3,
randMinMax: randMinMax3,
randNorm: randNorm3,
randNormDistrib: randNormDistrib3,
round: round3,
set: set3,
setN: setN3,
Expand All @@ -132,6 +147,7 @@ export const VEC3: VecAPI = {
subm: subm3,
submN: submN3,
tan: tan3,
trunc: trunc3,

eq: eq3,
neq: neq3,
Expand Down
16 changes: 16 additions & 0 deletions packages/vectors/src/vec4-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { fract4 } from "./fract.js";
import { gt4 } from "./gt.js";
import { gte4 } from "./gte.js";
import { invSqrt4 } from "./invsqrt.js";
import { limit4 } from "./limit.js";
import { log4 } from "./log.js";
import { log_24 } from "./log_2.js";
import { lt4 } from "./lt.js";
Expand All @@ -53,6 +54,13 @@ import { normalize4 } from "./normalize.js";
import { pow4 } from "./pow.js";
import { powN4 } from "./pown.js";
import { radians4 } from "./radians.js";
import {
randMinMax4,
randNorm4,
randNormDistrib4,
random4,
randomDistrib4,
} from "./random.js";
import { round4 } from "./round.js";
import { set4 } from "./set.js";
import { setN4 } from "./setn.js";
Expand All @@ -66,6 +74,7 @@ import { subm4 } from "./subm.js";
import { submN4 } from "./submn.js";
import { subN4 } from "./subn.js";
import { tan4 } from "./tan.js";
import { trunc4 } from "./trunc.js";

export const VEC4: VecAPI = {
abs: abs4,
Expand Down Expand Up @@ -101,6 +110,7 @@ export const VEC4: VecAPI = {
maddN: maddN4,
mag: mag4,
magSq: magSq4,
limit: limit4,
log: log4,
log2: log_24,
major: major4,
Expand All @@ -119,6 +129,11 @@ export const VEC4: VecAPI = {
pow: pow4,
powN: powN4,
radians: radians4,
random: random4,
randomDistrib: randomDistrib4,
randMinMax: randMinMax4,
randNorm: randNorm4,
randNormDistrib: randNormDistrib4,
round: round4,
set: set4,
setN: setN4,
Expand All @@ -132,6 +147,7 @@ export const VEC4: VecAPI = {
subm: subm4,
submN: submN4,
tan: tan4,
trunc: trunc4,

eq: eq4,
neq: neq4,
Expand Down

0 comments on commit 0d9f62b

Please sign in to comment.