@mojir/lits 2.1.8 → 2.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +380 -30
- package/dist/cli/reference/api.d.ts +3 -3
- package/dist/cli/reference/index.d.ts +6 -0
- package/dist/cli/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/dot.d.ts +1 -0
- package/dist/cli/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/getUnit.d.ts +2 -0
- package/dist/cli/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/scale.d.ts +1 -0
- package/dist/cli/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/subtract.d.ts +1 -0
- package/dist/cli/src/typeGuards/annotatedArrays.d.ts +4 -0
- package/dist/cli/src/utils/index.d.ts +1 -1
- package/dist/index.esm.js +379 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +379 -29
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +379 -29
- package/dist/lits.iife.js.map +1 -1
- package/dist/reference/api.d.ts +3 -3
- package/dist/reference/index.d.ts +6 -0
- package/dist/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/dot.d.ts +1 -0
- package/dist/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/getUnit.d.ts +2 -0
- package/dist/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/scale.d.ts +1 -0
- package/dist/src/builtin/normalExpressions/categories/namespaces/linearAlgebra/helpers/subtract.d.ts +1 -0
- package/dist/src/typeGuards/annotatedArrays.d.ts +4 -0
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/testFramework.esm.js +193 -28
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +193 -28
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -697,7 +697,7 @@ function deepEqual(a, b, sourceCodeInfo) {
|
|
|
697
697
|
if (a === b)
|
|
698
698
|
return true;
|
|
699
699
|
if (typeof a === 'number' && typeof b === 'number')
|
|
700
|
-
return Math.abs(a - b) <
|
|
700
|
+
return Math.abs(a - b) < 1e-10;
|
|
701
701
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
702
702
|
if (a.length !== b.length)
|
|
703
703
|
return false;
|
|
@@ -716,7 +716,7 @@ function deepEqual(a, b, sourceCodeInfo) {
|
|
|
716
716
|
return false;
|
|
717
717
|
for (var i = 0; i < aKeys.length; i += 1) {
|
|
718
718
|
var key = asString(aKeys[i], sourceCodeInfo);
|
|
719
|
-
if (!deepEqual(
|
|
719
|
+
if (!deepEqual(a[key], b[key], sourceCodeInfo))
|
|
720
720
|
return false;
|
|
721
721
|
}
|
|
722
722
|
return true;
|
|
@@ -2192,6 +2192,28 @@ function assertVector(vector, sourceCodeInfo) {
|
|
|
2192
2192
|
throw new LitsError("Expected a vector, but got ".concat(vector), sourceCodeInfo);
|
|
2193
2193
|
}
|
|
2194
2194
|
}
|
|
2195
|
+
function is2dVector(vector) {
|
|
2196
|
+
if (!isVector(vector)) {
|
|
2197
|
+
return false;
|
|
2198
|
+
}
|
|
2199
|
+
return vector.length === 2;
|
|
2200
|
+
}
|
|
2201
|
+
function assert2dVector(vector, sourceCodeInfo) {
|
|
2202
|
+
if (!is2dVector(vector)) {
|
|
2203
|
+
throw new LitsError("Expected a 2d vector, but got ".concat(vector), sourceCodeInfo);
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
function is3dVector(vector) {
|
|
2207
|
+
if (!isVector(vector)) {
|
|
2208
|
+
return false;
|
|
2209
|
+
}
|
|
2210
|
+
return vector.length === 3;
|
|
2211
|
+
}
|
|
2212
|
+
function assert3dVector(vector, sourceCodeInfo) {
|
|
2213
|
+
if (!is3dVector(vector)) {
|
|
2214
|
+
throw new LitsError("Expected a 3d vector, but got ".concat(vector), sourceCodeInfo);
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2195
2217
|
function assertNonEmptyVector(vector, sourceCodeInfo) {
|
|
2196
2218
|
assertVector(vector, sourceCodeInfo);
|
|
2197
2219
|
if (vector.length === 0) {
|
|
@@ -4572,6 +4594,24 @@ var gridNormalExpression = {
|
|
|
4572
4594
|
},
|
|
4573
4595
|
paramCount: 1,
|
|
4574
4596
|
},
|
|
4597
|
+
'grid:fill': {
|
|
4598
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
4599
|
+
var _b = __read(_a, 3), rows = _b[0], cols = _b[1], value = _b[2];
|
|
4600
|
+
assertNumber(rows, sourceCodeInfo, { integer: true, positive: true });
|
|
4601
|
+
assertNumber(cols, sourceCodeInfo, { integer: true, positive: true });
|
|
4602
|
+
assertAny(value, sourceCodeInfo);
|
|
4603
|
+
var result = [];
|
|
4604
|
+
for (var i = 0; i < rows; i += 1) {
|
|
4605
|
+
var row = [];
|
|
4606
|
+
for (var j = 0; j < cols; j += 1) {
|
|
4607
|
+
row.push(value);
|
|
4608
|
+
}
|
|
4609
|
+
result.push(row);
|
|
4610
|
+
}
|
|
4611
|
+
return result;
|
|
4612
|
+
},
|
|
4613
|
+
paramCount: 3,
|
|
4614
|
+
},
|
|
4575
4615
|
'grid:generate': {
|
|
4576
4616
|
evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
|
|
4577
4617
|
var _c = __read(_a, 3), rows = _c[0], cols = _c[1], generator = _c[2];
|
|
@@ -6516,7 +6556,137 @@ function extractOverlappingSegments(vectorA, vectorB, lag) {
|
|
|
6516
6556
|
return [segmentA, segmentB];
|
|
6517
6557
|
}
|
|
6518
6558
|
|
|
6559
|
+
function getUnit(value, sourceCodeInfo) {
|
|
6560
|
+
if (value.length === 0) {
|
|
6561
|
+
return value;
|
|
6562
|
+
}
|
|
6563
|
+
var length = Math.sqrt(value.reduce(function (acc, item) { return acc + Math.pow(item, 2); }, 0));
|
|
6564
|
+
if (approxZero(length)) {
|
|
6565
|
+
throw new LitsError('The vector must not be zero', sourceCodeInfo);
|
|
6566
|
+
}
|
|
6567
|
+
return value.map(function (item) { return item / length; });
|
|
6568
|
+
}
|
|
6569
|
+
|
|
6570
|
+
function dot(vector1, vector2) {
|
|
6571
|
+
return vector1.reduce(function (acc, item, index) { return acc + item * vector2[index]; }, 0);
|
|
6572
|
+
}
|
|
6573
|
+
|
|
6574
|
+
function subtract(vector1, vector2) {
|
|
6575
|
+
return vector1.map(function (item, index) { return item - vector2[index]; });
|
|
6576
|
+
}
|
|
6577
|
+
|
|
6578
|
+
function scale(vector, scalar) {
|
|
6579
|
+
return vector.map(function (item) { return item * scalar; });
|
|
6580
|
+
}
|
|
6581
|
+
|
|
6519
6582
|
var linearAlgebraNormalExpression = {
|
|
6583
|
+
'lin:rotate2d': {
|
|
6584
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
6585
|
+
var _b = __read(_a, 2), vector = _b[0], radians = _b[1];
|
|
6586
|
+
assert2dVector(vector, sourceCodeInfo);
|
|
6587
|
+
if (isZeroVector(vector)) {
|
|
6588
|
+
return vector;
|
|
6589
|
+
}
|
|
6590
|
+
assertNumber(radians, sourceCodeInfo, { finite: true });
|
|
6591
|
+
var cosTheta = Math.cos(radians);
|
|
6592
|
+
var sinTheta = Math.sin(radians);
|
|
6593
|
+
return [
|
|
6594
|
+
vector[0] * cosTheta - vector[1] * sinTheta,
|
|
6595
|
+
vector[0] * sinTheta + vector[1] * cosTheta,
|
|
6596
|
+
];
|
|
6597
|
+
},
|
|
6598
|
+
paramCount: 2,
|
|
6599
|
+
},
|
|
6600
|
+
'lin:rotate3d': {
|
|
6601
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
6602
|
+
var _b = __read(_a, 3), vector = _b[0], axis = _b[1], radians = _b[2];
|
|
6603
|
+
assert3dVector(vector, sourceCodeInfo);
|
|
6604
|
+
if (isZeroVector(vector)) {
|
|
6605
|
+
return vector;
|
|
6606
|
+
}
|
|
6607
|
+
assertNumber(radians, sourceCodeInfo, { finite: true });
|
|
6608
|
+
assert3dVector(axis, sourceCodeInfo);
|
|
6609
|
+
if (isZeroVector(axis)) {
|
|
6610
|
+
throw new LitsError('Rotation axis must not be zero', sourceCodeInfo);
|
|
6611
|
+
}
|
|
6612
|
+
var cosTheta = Math.cos(radians);
|
|
6613
|
+
var sinTheta = Math.sin(radians);
|
|
6614
|
+
var _c = __read(getUnit(axis, sourceCodeInfo), 3), u = _c[0], v = _c[1], w = _c[2];
|
|
6615
|
+
var dotProduct = vector[0] * u + vector[1] * v + vector[2] * w;
|
|
6616
|
+
return [
|
|
6617
|
+
dotProduct * u * (1 - cosTheta) + vector[0] * cosTheta + (-w * vector[1] + v * vector[2]) * sinTheta,
|
|
6618
|
+
dotProduct * v * (1 - cosTheta) + vector[1] * cosTheta + (w * vector[0] - u * vector[2]) * sinTheta,
|
|
6619
|
+
dotProduct * w * (1 - cosTheta) + vector[2] * cosTheta + (-v * vector[0] + u * vector[1]) * sinTheta,
|
|
6620
|
+
];
|
|
6621
|
+
},
|
|
6622
|
+
paramCount: 3,
|
|
6623
|
+
},
|
|
6624
|
+
'lin:reflect': {
|
|
6625
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
6626
|
+
var _b = __read(_a, 2), vector = _b[0], normal = _b[1];
|
|
6627
|
+
assertVector(vector, sourceCodeInfo);
|
|
6628
|
+
assertVector(normal, sourceCodeInfo);
|
|
6629
|
+
if (vector.length !== normal.length) {
|
|
6630
|
+
throw new LitsError('Vectors must be of the same length', sourceCodeInfo);
|
|
6631
|
+
}
|
|
6632
|
+
if (isZeroVector(normal)) {
|
|
6633
|
+
throw new LitsError('Reflection normal must not be zero', sourceCodeInfo);
|
|
6634
|
+
}
|
|
6635
|
+
if (isZeroVector(vector)) {
|
|
6636
|
+
return vector;
|
|
6637
|
+
}
|
|
6638
|
+
var unitNormal = getUnit(normal, sourceCodeInfo);
|
|
6639
|
+
var doubleDot = 2 * dot(vector, unitNormal);
|
|
6640
|
+
return subtract(vector, scale(unitNormal, doubleDot));
|
|
6641
|
+
},
|
|
6642
|
+
paramCount: 2,
|
|
6643
|
+
},
|
|
6644
|
+
'lin:refract': {
|
|
6645
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
6646
|
+
var _b = __read(_a, 3), vector = _b[0], normal = _b[1], eta = _b[2];
|
|
6647
|
+
assertVector(vector, sourceCodeInfo);
|
|
6648
|
+
assertVector(normal, sourceCodeInfo);
|
|
6649
|
+
assertNumber(eta, sourceCodeInfo, { finite: true, positive: true });
|
|
6650
|
+
if (vector.length !== normal.length) {
|
|
6651
|
+
throw new LitsError('Vectors must be of the same length', sourceCodeInfo);
|
|
6652
|
+
}
|
|
6653
|
+
if (isZeroVector(normal)) {
|
|
6654
|
+
throw new LitsError('Refraction normal must not be zero', sourceCodeInfo);
|
|
6655
|
+
}
|
|
6656
|
+
if (isZeroVector(vector)) {
|
|
6657
|
+
return vector;
|
|
6658
|
+
}
|
|
6659
|
+
// Make sure vectors are normalized
|
|
6660
|
+
var normalizedV = getUnit(vector, sourceCodeInfo);
|
|
6661
|
+
var normalizedNormal = getUnit(normal, sourceCodeInfo);
|
|
6662
|
+
// Calculate dot product between incident vector and normal
|
|
6663
|
+
var dotProduct = dot(normalizedV, normalizedNormal);
|
|
6664
|
+
// Calculate discriminant
|
|
6665
|
+
var discriminant = 1 - eta * eta * (1 - dotProduct * dotProduct);
|
|
6666
|
+
// Check for total internal reflection
|
|
6667
|
+
if (discriminant < 0) {
|
|
6668
|
+
return vector; // Total internal reflection occurs
|
|
6669
|
+
}
|
|
6670
|
+
// Calculate the refracted vector
|
|
6671
|
+
var scaledIncident = scale(normalizedV, eta);
|
|
6672
|
+
var scaledNormal = scale(normalizedNormal, eta * dotProduct + Math.sqrt(discriminant));
|
|
6673
|
+
return subtract(scaledIncident, scaledNormal);
|
|
6674
|
+
},
|
|
6675
|
+
paramCount: 3,
|
|
6676
|
+
},
|
|
6677
|
+
'lin:lerp': {
|
|
6678
|
+
evaluate: function (_a, sourceCodeInfo) {
|
|
6679
|
+
var _b = __read(_a, 3), vectorA = _b[0], vectorB = _b[1], t = _b[2];
|
|
6680
|
+
assertVector(vectorA, sourceCodeInfo);
|
|
6681
|
+
assertVector(vectorB, sourceCodeInfo);
|
|
6682
|
+
assertNumber(t, sourceCodeInfo, { finite: true });
|
|
6683
|
+
if (vectorA.length !== vectorB.length) {
|
|
6684
|
+
throw new LitsError('Vectors must be of the same length', sourceCodeInfo);
|
|
6685
|
+
}
|
|
6686
|
+
return vectorA.map(function (val, i) { return val + (vectorB[i] - val) * t; });
|
|
6687
|
+
},
|
|
6688
|
+
paramCount: 3,
|
|
6689
|
+
},
|
|
6520
6690
|
'lin:dot': {
|
|
6521
6691
|
evaluate: function (_a, sourceCodeInfo) {
|
|
6522
6692
|
var _b = __read(_a, 2), vectorA = _b[0], vectorB = _b[1];
|
|
@@ -6525,7 +6695,7 @@ var linearAlgebraNormalExpression = {
|
|
|
6525
6695
|
if (vectorA.length !== vectorB.length) {
|
|
6526
6696
|
throw new LitsError('Vectors must be of the same length', sourceCodeInfo);
|
|
6527
6697
|
}
|
|
6528
|
-
return vectorA
|
|
6698
|
+
return dot(vectorA, vectorB);
|
|
6529
6699
|
},
|
|
6530
6700
|
paramCount: 2,
|
|
6531
6701
|
},
|
|
@@ -6606,16 +6776,10 @@ var linearAlgebraNormalExpression = {
|
|
|
6606
6776
|
evaluate: function (_a, sourceCodeInfo) {
|
|
6607
6777
|
var _b = __read(_a, 1), vector = _b[0];
|
|
6608
6778
|
assertVector(vector, sourceCodeInfo);
|
|
6609
|
-
|
|
6610
|
-
return [];
|
|
6611
|
-
}
|
|
6612
|
-
var norm = Math.sqrt(vector.reduce(function (acc, val) { return acc + Math.pow(val, 2); }, 0));
|
|
6613
|
-
if (norm === 0) {
|
|
6614
|
-
return vector.map(function () { return 0; });
|
|
6615
|
-
}
|
|
6616
|
-
return vector.map(function (val) { return val / norm; });
|
|
6779
|
+
return getUnit(vector, sourceCodeInfo);
|
|
6617
6780
|
},
|
|
6618
6781
|
paramCount: 1,
|
|
6782
|
+
aliases: ['lin:unit', 'lin:normalize'],
|
|
6619
6783
|
},
|
|
6620
6784
|
'lin:normalize-log': {
|
|
6621
6785
|
evaluate: function (_a, sourceCodeInfo) {
|
|
@@ -6742,7 +6906,7 @@ var linearAlgebraNormalExpression = {
|
|
|
6742
6906
|
return Math.sqrt(vector.reduce(function (acc, val) { return acc + val * val; }, 0));
|
|
6743
6907
|
},
|
|
6744
6908
|
paramCount: 1,
|
|
6745
|
-
aliases: ['lin:l2-norm', 'lin:
|
|
6909
|
+
aliases: ['lin:l2-norm', 'lin:length'],
|
|
6746
6910
|
},
|
|
6747
6911
|
'lin:manhattan-distance': {
|
|
6748
6912
|
evaluate: function (_a, sourceCodeInfo) {
|
|
@@ -12367,6 +12531,7 @@ function evaluateReservedSymbol(node) {
|
|
|
12367
12531
|
return asNonUndefined(value, node[2]);
|
|
12368
12532
|
}
|
|
12369
12533
|
function evaluateNormalExpression(node, contextStack) {
|
|
12534
|
+
var _a, _b;
|
|
12370
12535
|
var sourceCodeInfo = node[2];
|
|
12371
12536
|
var paramNodes = node[1][1];
|
|
12372
12537
|
var params = [];
|
|
@@ -12392,14 +12557,14 @@ function evaluateNormalExpression(node, contextStack) {
|
|
|
12392
12557
|
var nameSymbol = node[1][0];
|
|
12393
12558
|
if (placeholders.length > 0) {
|
|
12394
12559
|
var fn = evaluateNode(nameSymbol, contextStack);
|
|
12395
|
-
var partialFunction = {
|
|
12396
|
-
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
params
|
|
12400
|
-
placeholders
|
|
12401
|
-
sourceCodeInfo
|
|
12402
|
-
|
|
12560
|
+
var partialFunction = (_a = {},
|
|
12561
|
+
_a[FUNCTION_SYMBOL] = true,
|
|
12562
|
+
_a.function = asFunctionLike(fn, sourceCodeInfo),
|
|
12563
|
+
_a.functionType = 'Partial',
|
|
12564
|
+
_a.params = params,
|
|
12565
|
+
_a.placeholders = placeholders,
|
|
12566
|
+
_a.sourceCodeInfo = sourceCodeInfo,
|
|
12567
|
+
_a);
|
|
12403
12568
|
return partialFunction;
|
|
12404
12569
|
}
|
|
12405
12570
|
if (isNormalBuiltinSymbolNode(nameSymbol)) {
|
|
@@ -12419,14 +12584,14 @@ function evaluateNormalExpression(node, contextStack) {
|
|
|
12419
12584
|
var fnNode = node[1][0];
|
|
12420
12585
|
var fn = asFunctionLike(evaluateNode(fnNode, contextStack), sourceCodeInfo);
|
|
12421
12586
|
if (placeholders.length > 0) {
|
|
12422
|
-
var partialFunction = {
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
params
|
|
12427
|
-
placeholders
|
|
12428
|
-
sourceCodeInfo
|
|
12429
|
-
|
|
12587
|
+
var partialFunction = (_b = {},
|
|
12588
|
+
_b[FUNCTION_SYMBOL] = true,
|
|
12589
|
+
_b.function = asFunctionLike(fn, sourceCodeInfo),
|
|
12590
|
+
_b.functionType = 'Partial',
|
|
12591
|
+
_b.params = params,
|
|
12592
|
+
_b.placeholders = placeholders,
|
|
12593
|
+
_b.sourceCodeInfo = sourceCodeInfo,
|
|
12594
|
+
_b);
|
|
12430
12595
|
return partialFunction;
|
|
12431
12596
|
}
|
|
12432
12597
|
return executeFunction(fn, params, contextStack, sourceCodeInfo);
|
|
@@ -14986,6 +15151,7 @@ var api = {
|
|
|
14986
15151
|
'grid:row',
|
|
14987
15152
|
'grid:col',
|
|
14988
15153
|
'grid:shape',
|
|
15154
|
+
'grid:fill',
|
|
14989
15155
|
'grid:generate',
|
|
14990
15156
|
'grid:reshape',
|
|
14991
15157
|
'grid:transpose',
|
|
@@ -15077,6 +15243,11 @@ var api = {
|
|
|
15077
15243
|
'vec:smape'
|
|
15078
15244
|
], __read(getVectorReductionNames('mean')), false), __read(getVectorReductionNames('median')), false), __read(getVectorReductionNames('variance')), false), __read(getVectorReductionNames('sample-variance')), false), __read(getVectorReductionNames('sum')), false), __read(getVectorReductionNames('prod')), false), __read(getVectorReductionNames('min')), false), __read(getVectorReductionNames('max')), false), __read(getVectorReductionNames('stdev')), false), __read(getVectorReductionNames('sample-stdev')), false), __read(getVectorReductionNames('iqr')), false), __read(getVectorReductionNames('span')), false), __read(getVectorReductionNames('geometric-mean')), false), __read(getVectorReductionNames('harmonic-mean')), false), __read(getVectorReductionNames('skewness')), false), __read(getVectorReductionNames('sample-skewness')), false), __read(getVectorReductionNames('kurtosis')), false), __read(getVectorReductionNames('sample-kurtosis')), false), __read(getVectorReductionNames('excess-kurtosis')), false), __read(getVectorReductionNames('sample-excess-kurtosis')), false), __read(getVectorReductionNames('rms')), false), __read(getVectorReductionNames('mad')), false), __read(getVectorReductionNames('medad')), false), __read(getVectorReductionNames('gini-coefficient')), false), __read(getVectorReductionNames('entropy')), false), __read(getVectorReductionNames('skewness')), false),
|
|
15079
15245
|
linAlg: [
|
|
15246
|
+
'lin:reflect',
|
|
15247
|
+
'lin:refract',
|
|
15248
|
+
'lin:lerp',
|
|
15249
|
+
'lin:rotate2d',
|
|
15250
|
+
'lin:rotate3d',
|
|
15080
15251
|
'lin:dot',
|
|
15081
15252
|
'lin:cross',
|
|
15082
15253
|
'lin:normalize-minmax',
|
|
@@ -18947,6 +19118,36 @@ var gridReference = {
|
|
|
18947
19118
|
"grid:shape(".concat(exampleGrid3, ")"),
|
|
18948
19119
|
],
|
|
18949
19120
|
},
|
|
19121
|
+
'grid:fill': {
|
|
19122
|
+
title: 'grid:fill',
|
|
19123
|
+
category: 'Grid',
|
|
19124
|
+
linkName: 'grid-colon-fill',
|
|
19125
|
+
returns: {
|
|
19126
|
+
type: 'grid',
|
|
19127
|
+
},
|
|
19128
|
+
args: {
|
|
19129
|
+
rows: {
|
|
19130
|
+
type: 'integer',
|
|
19131
|
+
description: 'The number of rows in the grid.',
|
|
19132
|
+
},
|
|
19133
|
+
cols: {
|
|
19134
|
+
type: 'integer',
|
|
19135
|
+
description: 'The number of columns in the grid.',
|
|
19136
|
+
},
|
|
19137
|
+
value: {
|
|
19138
|
+
type: 'any',
|
|
19139
|
+
description: 'The value to fill the grid with.',
|
|
19140
|
+
},
|
|
19141
|
+
},
|
|
19142
|
+
variants: [
|
|
19143
|
+
{ argumentNames: ['rows', 'cols', 'value'] },
|
|
19144
|
+
],
|
|
19145
|
+
description: 'Creates a grid of the specified size, filled with the specified value.',
|
|
19146
|
+
examples: [
|
|
19147
|
+
'grid:fill(2, 3, 0)',
|
|
19148
|
+
'grid:fill(2, 3, "x")',
|
|
19149
|
+
],
|
|
19150
|
+
},
|
|
18950
19151
|
'grid:generate': {
|
|
18951
19152
|
title: 'grid:generate',
|
|
18952
19153
|
category: 'Grid',
|
|
@@ -23169,6 +23370,150 @@ var vectorReference = __assign(__assign(__assign(__assign(__assign(__assign(__as
|
|
|
23169
23370
|
} });
|
|
23170
23371
|
|
|
23171
23372
|
var linAlgReference = {
|
|
23373
|
+
'lin:reflect': {
|
|
23374
|
+
title: 'lin:reflect',
|
|
23375
|
+
category: 'Linear Algebra',
|
|
23376
|
+
description: 'Reflects a vector across a given axis.',
|
|
23377
|
+
linkName: 'lin-colon-reflect',
|
|
23378
|
+
returns: {
|
|
23379
|
+
type: 'vector',
|
|
23380
|
+
},
|
|
23381
|
+
args: {
|
|
23382
|
+
a: {
|
|
23383
|
+
type: 'vector',
|
|
23384
|
+
description: 'Vector to reflect.',
|
|
23385
|
+
},
|
|
23386
|
+
b: {
|
|
23387
|
+
type: 'vector',
|
|
23388
|
+
description: 'Axis of reflection.',
|
|
23389
|
+
},
|
|
23390
|
+
},
|
|
23391
|
+
variants: [
|
|
23392
|
+
{ argumentNames: ['a', 'b'] },
|
|
23393
|
+
],
|
|
23394
|
+
examples: [
|
|
23395
|
+
'lin:reflect([1, 2], [0, 1])',
|
|
23396
|
+
'lin:reflect([1, 2, 3], [0, 0, 1])',
|
|
23397
|
+
],
|
|
23398
|
+
},
|
|
23399
|
+
'lin:refract': {
|
|
23400
|
+
title: 'lin:refract',
|
|
23401
|
+
category: 'Linear Algebra',
|
|
23402
|
+
description: 'Refracts a vector across a given axis.',
|
|
23403
|
+
linkName: 'lin-colon-refract',
|
|
23404
|
+
returns: {
|
|
23405
|
+
type: 'vector',
|
|
23406
|
+
},
|
|
23407
|
+
args: {
|
|
23408
|
+
vector: {
|
|
23409
|
+
type: 'vector',
|
|
23410
|
+
description: 'Vector to refract.',
|
|
23411
|
+
},
|
|
23412
|
+
axis: {
|
|
23413
|
+
type: 'vector',
|
|
23414
|
+
description: 'Axis of refraction.',
|
|
23415
|
+
},
|
|
23416
|
+
eta: {
|
|
23417
|
+
type: 'number',
|
|
23418
|
+
description: 'Refraction index.',
|
|
23419
|
+
},
|
|
23420
|
+
},
|
|
23421
|
+
variants: [
|
|
23422
|
+
{ argumentNames: ['vector', 'axis', 'eta'] },
|
|
23423
|
+
],
|
|
23424
|
+
examples: [
|
|
23425
|
+
'lin:refract([1, 2], [0, 1], 1.5)',
|
|
23426
|
+
'lin:refract([1, 2, 3], [0, 0, 1], 1.5)',
|
|
23427
|
+
],
|
|
23428
|
+
},
|
|
23429
|
+
'lin:lerp': {
|
|
23430
|
+
title: 'lin:lerp',
|
|
23431
|
+
category: 'Linear Algebra',
|
|
23432
|
+
description: 'Performs linear interpolation between two vectors.',
|
|
23433
|
+
linkName: 'lin-colon-lerp',
|
|
23434
|
+
returns: {
|
|
23435
|
+
type: 'vector',
|
|
23436
|
+
},
|
|
23437
|
+
args: {
|
|
23438
|
+
a: {
|
|
23439
|
+
type: 'vector',
|
|
23440
|
+
description: 'Start vector.',
|
|
23441
|
+
},
|
|
23442
|
+
b: {
|
|
23443
|
+
type: 'vector',
|
|
23444
|
+
description: 'End vector.',
|
|
23445
|
+
},
|
|
23446
|
+
t: {
|
|
23447
|
+
type: 'number',
|
|
23448
|
+
description: 'Interpolation factor (0 to 1).',
|
|
23449
|
+
},
|
|
23450
|
+
},
|
|
23451
|
+
variants: [
|
|
23452
|
+
{ argumentNames: ['a', 'b', 't'] },
|
|
23453
|
+
],
|
|
23454
|
+
examples: [
|
|
23455
|
+
'lin:lerp([1, 2], [3, 4], 0.5)',
|
|
23456
|
+
'lin:lerp([1, 2], [3, 4], 2)',
|
|
23457
|
+
'lin:lerp([1, 2], [3, 4], -1)',
|
|
23458
|
+
'lin:lerp([1, 2, 3], [4, 5, 6], 0.25)',
|
|
23459
|
+
],
|
|
23460
|
+
},
|
|
23461
|
+
'lin:rotate2d': {
|
|
23462
|
+
title: 'lin:rotate2d',
|
|
23463
|
+
category: 'Linear Algebra',
|
|
23464
|
+
description: 'Rotates a 2D vector by a given angle in radians.',
|
|
23465
|
+
linkName: 'lin-colon-rotate2d',
|
|
23466
|
+
returns: {
|
|
23467
|
+
type: 'vector',
|
|
23468
|
+
},
|
|
23469
|
+
args: {
|
|
23470
|
+
a: {
|
|
23471
|
+
type: 'vector',
|
|
23472
|
+
description: 'Vector to rotate.',
|
|
23473
|
+
},
|
|
23474
|
+
b: {
|
|
23475
|
+
type: 'number',
|
|
23476
|
+
description: 'Angle in b.',
|
|
23477
|
+
},
|
|
23478
|
+
},
|
|
23479
|
+
variants: [
|
|
23480
|
+
{ argumentNames: ['a', 'b'] },
|
|
23481
|
+
],
|
|
23482
|
+
examples: [
|
|
23483
|
+
'lin:rotate2d([1, 0], PI / 2)',
|
|
23484
|
+
'lin:rotate2d([0, 1], PI)',
|
|
23485
|
+
],
|
|
23486
|
+
},
|
|
23487
|
+
'lin:rotate3d': {
|
|
23488
|
+
title: 'lin:rotate3d',
|
|
23489
|
+
category: 'Linear Algebra',
|
|
23490
|
+
description: 'Rotates a 3D vector around a given axis by a given angle in radians.',
|
|
23491
|
+
linkName: 'lin-colon-rotate3d',
|
|
23492
|
+
returns: {
|
|
23493
|
+
type: 'vector',
|
|
23494
|
+
},
|
|
23495
|
+
args: {
|
|
23496
|
+
v: {
|
|
23497
|
+
type: 'vector',
|
|
23498
|
+
description: 'Vector to rotate.',
|
|
23499
|
+
},
|
|
23500
|
+
axis: {
|
|
23501
|
+
type: 'vector',
|
|
23502
|
+
description: 'Axis of rotation.',
|
|
23503
|
+
},
|
|
23504
|
+
radians: {
|
|
23505
|
+
type: 'number',
|
|
23506
|
+
description: 'Angle in radians.',
|
|
23507
|
+
},
|
|
23508
|
+
},
|
|
23509
|
+
variants: [
|
|
23510
|
+
{ argumentNames: ['v', 'axis', 'radians'] },
|
|
23511
|
+
],
|
|
23512
|
+
examples: [
|
|
23513
|
+
'lin:rotate3d([1, 0, 0], [0, 1, 0], PI / 2)',
|
|
23514
|
+
'lin:rotate3d([0, 1, 0], [1, 0, 0], PI)',
|
|
23515
|
+
],
|
|
23516
|
+
},
|
|
23172
23517
|
'lin:dot': {
|
|
23173
23518
|
title: 'lin:dot',
|
|
23174
23519
|
category: 'Linear Algebra',
|
|
@@ -23343,11 +23688,16 @@ var linAlgReference = {
|
|
|
23343
23688
|
],
|
|
23344
23689
|
examples: [
|
|
23345
23690
|
'lin:normalize-l2([1, 2, 3])',
|
|
23691
|
+
'lin:unit([1, 2, 3])',
|
|
23346
23692
|
'lin:normalize-l2([1, 2, -3])',
|
|
23347
23693
|
'lin:normalize-l2([1, 2, 3, 4])',
|
|
23348
23694
|
'lin:normalize-l2([1, 2, -3, 4])',
|
|
23349
23695
|
'lin:normalize-l2([1, 2, 3, 40, 50])',
|
|
23350
23696
|
],
|
|
23697
|
+
aliases: [
|
|
23698
|
+
'lin:unit',
|
|
23699
|
+
'lin:normalize',
|
|
23700
|
+
],
|
|
23351
23701
|
},
|
|
23352
23702
|
'lin:normalize-log': {
|
|
23353
23703
|
title: 'lin:normalize-log',
|
|
@@ -23525,7 +23875,7 @@ var linAlgReference = {
|
|
|
23525
23875
|
],
|
|
23526
23876
|
aliases: [
|
|
23527
23877
|
'lin:l2-norm',
|
|
23528
|
-
'lin:
|
|
23878
|
+
'lin:length',
|
|
23529
23879
|
],
|
|
23530
23880
|
},
|
|
23531
23881
|
'lin:manhattan-distance': {
|