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