es6-fuzz 6.0.9 → 7.0.1

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 (51) hide show
  1. package/CONTRIBUTING.md +87 -0
  2. package/Readme.md +26 -10
  3. package/SECURITY.md +4 -5
  4. package/lib/curve/constant.d.ts +4 -3
  5. package/lib/curve/constant.d.ts.map +1 -1
  6. package/lib/curve/constant.js +5 -2
  7. package/lib/curve/constant.js.map +1 -1
  8. package/lib/curve/fuzzifier.d.ts +17 -0
  9. package/lib/curve/fuzzifier.d.ts.map +1 -0
  10. package/lib/curve/fuzzifier.js +3 -0
  11. package/lib/curve/fuzzifier.js.map +1 -0
  12. package/lib/curve/fuzzy-function.d.ts +2 -1
  13. package/lib/curve/fuzzy-function.d.ts.map +1 -1
  14. package/lib/curve/fuzzy-function.js +1 -1
  15. package/lib/curve/fuzzy-function.js.map +1 -1
  16. package/lib/curve/grade.d.ts +6 -0
  17. package/lib/curve/grade.d.ts.map +1 -1
  18. package/lib/curve/grade.js +14 -4
  19. package/lib/curve/grade.js.map +1 -1
  20. package/lib/curve/reverse-grade.d.ts +11 -1
  21. package/lib/curve/reverse-grade.d.ts.map +1 -1
  22. package/lib/curve/reverse-grade.js +25 -17
  23. package/lib/curve/reverse-grade.js.map +1 -1
  24. package/lib/curve/shape.d.ts +2 -1
  25. package/lib/curve/shape.d.ts.map +1 -1
  26. package/lib/curve/shape.js +4 -4
  27. package/lib/curve/shape.js.map +1 -1
  28. package/lib/curve/sigmoid.d.ts +5 -2
  29. package/lib/curve/sigmoid.d.ts.map +1 -1
  30. package/lib/curve/sigmoid.js +3 -1
  31. package/lib/curve/sigmoid.js.map +1 -1
  32. package/lib/curve/trapezoid.js +4 -4
  33. package/lib/curve/trapezoid.js.map +1 -1
  34. package/lib/curve/triangle.d.ts +7 -0
  35. package/lib/curve/triangle.d.ts.map +1 -1
  36. package/lib/curve/triangle.js +11 -2
  37. package/lib/curve/triangle.js.map +1 -1
  38. package/lib/index.d.ts +11 -0
  39. package/lib/index.d.ts.map +1 -0
  40. package/lib/index.js +22 -0
  41. package/lib/index.js.map +1 -0
  42. package/lib/logic.d.ts +62 -5
  43. package/lib/logic.d.ts.map +1 -1
  44. package/lib/logic.js +96 -40
  45. package/lib/logic.js.map +1 -1
  46. package/lib/render-examples.js +92 -36
  47. package/lib/render-examples.js.map +1 -1
  48. package/lib/svg-renderer.d.ts.map +1 -1
  49. package/lib/svg-renderer.js +18 -9
  50. package/lib/svg-renderer.js.map +1 -1
  51. package/package.json +25 -16
@@ -0,0 +1,87 @@
1
+ # Contributing to es6-fuzz
2
+
3
+ Thanks for your interest in improving es6-fuzz! This guide covers the local
4
+ workflow and the conventions used in this repository.
5
+
6
+ ## Prerequisites
7
+
8
+ - Node.js 22+ (see `engines` in [package.json](package.json))
9
+ - npm
10
+
11
+ `package-lock.json` is intentionally not committed, so use `npm install`
12
+ (not `npm ci`).
13
+
14
+ ## Getting started
15
+
16
+ ```bash
17
+ git clone https://github.com/sebs/es6-fuzz.git
18
+ cd es6-fuzz
19
+ npm install
20
+ npm test
21
+ ```
22
+
23
+ ## Common scripts
24
+
25
+ | Script | What it does |
26
+ | --- | --- |
27
+ | `npm run build` | Clean `lib/` and compile TypeScript |
28
+ | `npm test` | Build, then run the test suite |
29
+ | `npm run test:coverage` | Run the suite with a coverage report |
30
+ | `npm run check` | Strict type-check (`tsc --noEmit`) without emitting |
31
+ | `npm run docs` | Generate the TypeDoc API site into `out/` |
32
+ | `npm run render-examples` | Render fuzzifier SVGs + viewer into `examples/` |
33
+
34
+ Generated output (`lib/`, `out/`, `docs/CHANGELOG.md`, `examples/`) is not
35
+ committed — it is produced by the build and CI pipeline.
36
+
37
+ ## Tests
38
+
39
+ Tests use the built-in Node.js test runner (`node:test`) executed via `tsx`,
40
+ and live under [test/](test/). Test files import from the compiled `lib/`
41
+ output, which is why `npm test` builds first. Please add or update tests for any
42
+ behavior change, and keep the suite green:
43
+
44
+ ```bash
45
+ npm test
46
+ npm run check
47
+ ```
48
+
49
+ ## Coding conventions
50
+
51
+ - TypeScript in `strict` mode — no new type errors (`npm run check`).
52
+ - Each fuzzifier implements the `Fuzzify` contract in
53
+ [src/curve/fuzzifier.ts](src/curve/fuzzifier.ts) and maps a crisp input to a
54
+ membership degree in `0..1`.
55
+ - Match the style of the surrounding code.
56
+
57
+ ## Commit messages
58
+
59
+ This project uses [Conventional Commits](https://www.conventionalcommits.org/)
60
+ prefixes — e.g. `feat:`, `fix:`, `chore:`, `ci:`, `build:`, `refactor:`,
61
+ `docs:`. Keep commits focused and the subject line imperative.
62
+
63
+ ## Submitting changes
64
+
65
+ 1. Fork and branch from `master`.
66
+ 2. Make your change with tests and passing `npm test` / `npm run check`.
67
+ 3. Open a pull request describing the change and the motivation.
68
+
69
+ CI runs the test suite and the strict type-check on Node 22 and 24
70
+ (see [.github/workflows/ci.yml](.github/workflows/ci.yml)).
71
+
72
+ ## Releases
73
+
74
+ Maintainers release by bumping the version, which creates a matching tag:
75
+
76
+ ```bash
77
+ npm version <patch|minor|major> # postversion pushes the commit + tag
78
+ ```
79
+
80
+ Pushing the `v*` tag triggers the release workflow (builds, packs, and
81
+ generates release notes); publishing to npm is a separate, manually dispatched
82
+ workflow.
83
+
84
+ ## License
85
+
86
+ By contributing you agree that your contributions are licensed under the
87
+ project's [MIT License](LICENSE.md).
package/Readme.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  > Fuzzy Logic in JavaScript
4
4
 
5
+ [![CI](https://github.com/sebs/es6-fuzz/actions/workflows/ci.yml/badge.svg)](https://github.com/sebs/es6-fuzz/actions/workflows/ci.yml)
5
6
  [![npm](https://img.shields.io/npm/dt/es6-fuzz.svg)](https://www.npmjs.com/package/es6-fuzz)
6
7
  [![license](https://img.shields.io/github/license/sebs/es6-fuzz.svg)](https://github.com/sebs/es6-fuzz/blob/master/LICENSE.md)
7
8
  [![GitHub tag](https://img.shields.io/github/tag/sebs/es6-fuzz.svg)](https://github.com/sebs/es6-fuzz)
@@ -14,12 +15,11 @@
14
15
  * **Reverse Grade** - Inverted linear membership
15
16
  * **Sigmoid** - S-shaped membership curve
16
17
  * **Trapezoid** - Trapezoidal membership function
17
- * **Triangle** - Triangular membership function
18
-
18
+ * **Triangle** - Triangular membership functionve
19
19
  ## Documentation
20
20
 
21
21
  * [API Documentation](http://sebs.github.io/es6-fuzz)
22
- * [Changelog](https://github.com/sebs/es6-fuzz/blob/master/docs/CHANGELOG.md)
22
+ * [Changelog](https://github.com/sebs/es6-fuzz/releases)
23
23
 
24
24
  ## Installation
25
25
 
@@ -37,9 +37,9 @@ const result = logic
37
37
  .init('noAttack', new Triangle(0, 20, 40))
38
38
  .or('normalAttack', new Trapezoid(20, 30, 90, 100))
39
39
  .or('enragedAttack', new Grade(90, 100))
40
- .defuzzify(40);
40
+ .defuzzify(99);
41
41
 
42
- console.log(result); // 'enragedAttack'
42
+ console.log(result.toString()); // 'enragedAttack'
43
43
  ```
44
44
 
45
45
  ## Temperature Example
@@ -55,7 +55,7 @@ const result = logic
55
55
  .or('hot', new Trapezoid(12, 14, 16, 100))
56
56
  .defuzzify(20);
57
57
 
58
- console.log(result); // 'hot'
58
+ console.log(result.toString()); // 'hot'
59
59
  ```
60
60
 
61
61
 
@@ -104,19 +104,35 @@ console.log(monsterBiteTest(jsBoonInput)); // true
104
104
  ### Running Tests
105
105
 
106
106
  ```bash
107
- npm test
107
+ npm test # build + run the test suite
108
+ npm run test:coverage # same, with a coverage report
108
109
  ```
109
110
 
110
111
  ### Building Documentation
111
112
 
112
113
  ```bash
113
- npm run docs # Generate API docs
114
- npm run docs:site # Build documentation site
114
+ npm run docs # Generate the TypeDoc API site into ./out
115
+ ```
116
+
117
+ The site is deployed to GitHub Pages automatically on every push to `master`
118
+ by the [Docs workflow](.github/workflows/docs.yml); `npm run docs` is for local
119
+ preview.
120
+
121
+ ### Visual Examples
122
+
123
+ The `render-examples` script renders every fuzzifier and a few composite
124
+ systems (temperature/speed controllers) to SVG, plus an `index.html` viewer:
125
+
126
+ ```bash
127
+ npm run build # render-examples runs from the compiled output
128
+ npm run render-examples # writes SVGs + index.html into ./examples
115
129
  ```
116
130
 
131
+ Open `examples/index.html` in a browser to see the membership curves.
132
+
117
133
  ## Requirements
118
134
 
119
- * Node.js 20+
135
+ * Node.js 22+
120
136
 
121
137
  ## Resources
122
138
 
package/SECURITY.md CHANGED
@@ -2,14 +2,13 @@
2
2
 
3
3
  ## Supported Versions
4
4
 
5
- Use this section to tell people about which versions of your project are
6
- currently being supported with security updates.
5
+ The following versions of es6-fuzz are currently supported with security updates:
7
6
 
8
7
  | Version | Supported |
9
8
  | ------- | ------------------ |
10
- | 5.1.x | :white_check_mark: |
11
- | 5.0.x | :x: |
12
- | 4.0.x | :X:|
9
+ | 6.0.x | :white_check_mark: |
10
+ | 5.x.x | :x: |
11
+ | 4.x.x | :x: |
13
12
  | < 4.0 | :x: |
14
13
 
15
14
  ## Reporting a Vulnerability
@@ -1,11 +1,12 @@
1
+ import { Fuzzifier } from './fuzzifier';
1
2
  /** Class representing a Constant. */
2
- export declare class Constant {
3
+ export declare class Constant implements Fuzzifier {
3
4
  private readonly cValue;
4
5
  /**
5
6
  * Create a Constant Value.
6
- * @param {number} constantValue - The value.
7
+ * @param {number} constantValue - The membership value, must be within 0..1.
7
8
  * @example
8
- * new Constant(10)
9
+ * new Constant(0.5)
9
10
  */
10
11
  constructor(constantValue: number);
11
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/curve/constant.ts"],"names":[],"mappings":"AACA,qCAAqC;AACrC,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;OAKG;gBACS,aAAa,EAAE,MAAM;IAGjC;;;OAGG;IACH,OAAO,IAAI,MAAM;CAGlB"}
1
+ {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/curve/constant.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,qCAAqC;AACrC,qBAAa,QAAS,YAAW,SAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;OAKG;gBACS,aAAa,EAAE,MAAM;IAMjC;;;OAGG;IACH,OAAO,IAAI,MAAM;CAGlB"}
@@ -6,11 +6,14 @@ class Constant {
6
6
  cValue;
7
7
  /**
8
8
  * Create a Constant Value.
9
- * @param {number} constantValue - The value.
9
+ * @param {number} constantValue - The membership value, must be within 0..1.
10
10
  * @example
11
- * new Constant(10)
11
+ * new Constant(0.5)
12
12
  */
13
13
  constructor(constantValue) {
14
+ if (!(constantValue >= 0 && constantValue <= 1)) {
15
+ throw Error('Constant value must be between 0 and 1 but is ' + constantValue);
16
+ }
14
17
  this.cValue = constantValue;
15
18
  }
16
19
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/curve/constant.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,qCAAqC;AACrC,MAAa,QAAQ;IACF,MAAM,CAAS;IAEhC;;;;;OAKG;IACH,YAAY,aAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;IAC9B,CAAC;IACD;;;OAGG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAnBD,4BAmBC"}
1
+ {"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/curve/constant.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,qCAAqC;AACrC,MAAa,QAAQ;IACF,MAAM,CAAS;IAEhC;;;;;OAKG;IACH,YAAY,aAAqB;QAC/B,IAAI,CAAC,CAAC,aAAa,IAAI,CAAC,IAAI,aAAa,IAAI,CAAC,CAAC,EAAE,CAAC;YAChD,MAAM,KAAK,CAAC,gDAAgD,GAAG,aAAa,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;IAC9B,CAAC;IACD;;;OAGG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAtBD,4BAsBC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Common interface implemented by every fuzzifier.
3
+ *
4
+ * Anything that maps a crisp input value to a membership degree can be used
5
+ * with {@link Logic}. This includes the geometric {@link Shape} curves as well
6
+ * as {@link Constant}, {@link Sigmoid} and {@link FuzzyFunction}, none of which
7
+ * are point-based shapes.
8
+ */
9
+ export interface Fuzzifier {
10
+ /**
11
+ * Fuzzify
12
+ * @param {number} val - Point on X axis
13
+ * @return {number} fuzzy output 0..1
14
+ */
15
+ fuzzify(val: number): number;
16
+ }
17
+ //# sourceMappingURL=fuzzifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fuzzifier.d.ts","sourceRoot":"","sources":["../../src/curve/fuzzifier.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B"}
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=fuzzifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fuzzifier.js","sourceRoot":"","sources":["../../src/curve/fuzzifier.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { Fuzzifier } from './fuzzifier';
1
2
  /** Class representing a FuzzyFunction. */
2
- export declare class FuzzyFunction {
3
+ export declare class FuzzyFunction implements Fuzzifier {
3
4
  private readonly cb;
4
5
  /**
5
6
  * Create a FuzzyFunction.
@@ -1 +1 @@
1
- {"version":3,"file":"fuzzy-function.d.ts","sourceRoot":"","sources":["../../src/curve/fuzzy-function.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA0B;IAE7C;;;OAGG;gBACS,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM;IAGvC;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAO7B"}
1
+ {"version":3,"file":"fuzzy-function.d.ts","sourceRoot":"","sources":["../../src/curve/fuzzy-function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,0CAA0C;AAC1C,qBAAa,aAAc,YAAW,SAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA0B;IAE7C;;;OAGG;gBACS,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM;IAGvC;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAO7B"}
@@ -20,7 +20,7 @@ class FuzzyFunction {
20
20
  if (res >= 0 && res <= 1) {
21
21
  return res;
22
22
  }
23
- throw Error('fuzzified result must be smaller than 1 but greater than 0 but is' + res);
23
+ throw Error('fuzzified result must be between 0 and 1 but is ' + res);
24
24
  }
25
25
  }
26
26
  exports.FuzzyFunction = FuzzyFunction;
@@ -1 +1 @@
1
- {"version":3,"file":"fuzzy-function.js","sourceRoot":"","sources":["../../src/curve/fuzzy-function.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,MAAa,aAAa;IACP,EAAE,CAA0B;IAE7C;;;OAGG;IACH,YAAY,EAA2B;QACrC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IACD;;;OAGG;IACH,OAAO,CAAC,GAAW;QACjB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO,GAAG,CAAC;QACb,CAAC;QACD,MAAM,KAAK,CAAC,mEAAmE,GAAG,GAAG,CAAC,CAAC;IACzF,CAAC;CACF;AArBD,sCAqBC"}
1
+ {"version":3,"file":"fuzzy-function.js","sourceRoot":"","sources":["../../src/curve/fuzzy-function.ts"],"names":[],"mappings":";;;AACA,0CAA0C;AAC1C,MAAa,aAAa;IACP,EAAE,CAA0B;IAE7C;;;OAGG;IACH,YAAY,EAA2B;QACrC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IACD;;;OAGG;IACH,OAAO,CAAC,GAAW;QACjB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO,GAAG,CAAC;QACb,CAAC;QACD,MAAM,KAAK,CAAC,kDAAkD,GAAG,GAAG,CAAC,CAAC;IACxE,CAAC;CACF;AArBD,sCAqBC"}
@@ -5,6 +5,12 @@ import { Shape } from './shape';
5
5
  * new Grade(0, 10)
6
6
  */
7
7
  export declare class Grade extends Shape {
8
+ /**
9
+ * Create a Grade.
10
+ * @param {number} x0 - start of the rising edge (membership 0)
11
+ * @param {number} x1 - end of the rising edge (membership 1)
12
+ */
13
+ constructor(x0: number, x1: number);
8
14
  /**
9
15
  * Fuzzify
10
16
  * @param {number} val - Point on X axis
@@ -1 +1 @@
1
- {"version":3,"file":"grade.d.ts","sourceRoot":"","sources":["../../src/curve/grade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC;;;;GAIG;AACH,qBAAa,KAAM,SAAQ,KAAK;IAC9B;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAmB7B"}
1
+ {"version":3,"file":"grade.d.ts","sourceRoot":"","sources":["../../src/curve/grade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC;;;;GAIG;AACH,qBAAa,KAAM,SAAQ,KAAK;IAC9B;;;;OAIG;gBACS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAGlC;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAqB7B"}
@@ -8,6 +8,14 @@ const shape_1 = require("./shape");
8
8
  * new Grade(0, 10)
9
9
  */
10
10
  class Grade extends shape_1.Shape {
11
+ /**
12
+ * Create a Grade.
13
+ * @param {number} x0 - start of the rising edge (membership 0)
14
+ * @param {number} x1 - end of the rising edge (membership 1)
15
+ */
16
+ constructor(x0, x1) {
17
+ super(x0, x1, x1, x1);
18
+ }
11
19
  /**
12
20
  * Fuzzify
13
21
  * @param {number} val - Point on X axis
@@ -16,11 +24,13 @@ class Grade extends shape_1.Shape {
16
24
  fuzzify(val) {
17
25
  let result = 0;
18
26
  const x = val;
19
- // Handle case where x0 = x1 (vertical grade/step function)
27
+ // Handle case where x0 = x1 (vertical grade/step function).
28
+ // Treat it as the limit of the ramp: the foot at x0 is 0, like the normal
29
+ // grade below, so behaviour stays continuous as x1 approaches x0.
20
30
  if (this.x1 === this.x0) {
21
- if (x < this.x0)
31
+ if (x <= this.x0)
22
32
  return 0;
23
- return 1; // x >= x0
33
+ return 1; // x > x0
24
34
  }
25
35
  if (x <= this.x0) {
26
36
  result = 0;
@@ -29,7 +39,7 @@ class Grade extends shape_1.Shape {
29
39
  result = 1;
30
40
  }
31
41
  else {
32
- result = (x / (this.x1 - this.x0)) - (this.x0 / (this.x1 - this.x0));
42
+ result = x / (this.x1 - this.x0) - this.x0 / (this.x1 - this.x0);
33
43
  }
34
44
  return result;
35
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"grade.js","sourceRoot":"","sources":["../../src/curve/grade.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAgC;AAChC;;;;GAIG;AACH,MAAa,KAAM,SAAQ,aAAK;IAC9B;;;;OAIG;IACH,OAAO,CAAC,GAAW;QACjB,IAAI,MAAM,GAAG,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AI,IAAI,CAAC,EAAE;gBAAE,OAAO,CAAC,CAAC;YAC3B,OAAO,CAAC,CAAC,CAAC,SAAS;QACrB,CAAC;QAED,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACxB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAnCD,sBAmCC"}
@@ -1,6 +1,16 @@
1
1
  import { Shape } from './shape';
2
- /** Class representing a ReverseGrade. */
2
+ /**
3
+ * Class representing a ReverseGrade.
4
+ * @example
5
+ * new ReverseGrade(0, 10)
6
+ */
3
7
  export declare class ReverseGrade extends Shape {
8
+ /**
9
+ * Create a ReverseGrade.
10
+ * @param {number} x0 - end of the full-membership plateau (membership 1)
11
+ * @param {number} x1 - end of the falling edge (membership 0)
12
+ */
13
+ constructor(x0: number, x1: number);
4
14
  /**
5
15
  * Fuzzify
6
16
  * @param {number} val - Point on X axis
@@ -1 +1 @@
1
- {"version":3,"file":"reverse-grade.d.ts","sourceRoot":"","sources":["../../src/curve/reverse-grade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,yCAAyC;AACzC,qBAAa,YAAa,SAAQ,KAAK;IACrC;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAkB7B"}
1
+ {"version":3,"file":"reverse-grade.d.ts","sourceRoot":"","sources":["../../src/curve/reverse-grade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC;;;;OAIG;gBACS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAGlC;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAe7B"}
@@ -2,32 +2,40 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ReverseGrade = void 0;
4
4
  const shape_1 = require("./shape");
5
- /** Class representing a ReverseGrade. */
5
+ /**
6
+ * Class representing a ReverseGrade.
7
+ * @example
8
+ * new ReverseGrade(0, 10)
9
+ */
6
10
  class ReverseGrade extends shape_1.Shape {
11
+ /**
12
+ * Create a ReverseGrade.
13
+ * @param {number} x0 - end of the full-membership plateau (membership 1)
14
+ * @param {number} x1 - end of the falling edge (membership 0)
15
+ */
16
+ constructor(x0, x1) {
17
+ super(x0, x1, x1, x1);
18
+ }
7
19
  /**
8
20
  * Fuzzify
9
21
  * @param {number} val - Point on X axis
10
22
  * @return {number} fuzzy output 0..1
11
23
  */
12
24
  fuzzify(val) {
13
- let result = 0;
14
25
  const x = val;
15
- if (x <= this.x0) {
16
- result = 1;
17
- }
18
- else if (x >= this.x1) {
19
- result = 0;
20
- }
21
- else {
22
- // Handle case where x0 = x1 (vertical reverse grade)
23
- if (this.x1 === this.x0) {
24
- result = 0;
25
- }
26
- else {
27
- result = (-x / (this.x1 - this.x0)) + (this.x1 / (this.x1 - this.x0));
28
- }
26
+ // Vertical reverse grade (x0 = x1): step down, the mirror of Grade.
27
+ // (The previous inline x0 === x1 handling sat in an unreachable branch:
28
+ // when x0 === x1 every value is caught by x <= x0 or x >= x1 first.)
29
+ if (this.x1 === this.x0) {
30
+ if (x <= this.x0)
31
+ return 1;
32
+ return 0; // x > x0
29
33
  }
30
- return result;
34
+ if (x <= this.x0)
35
+ return 1;
36
+ if (x >= this.x1)
37
+ return 0;
38
+ return -x / (this.x1 - this.x0) + this.x1 / (this.x1 - this.x0);
31
39
  }
32
40
  }
33
41
  exports.ReverseGrade = ReverseGrade;
@@ -1 +1 @@
1
- {"version":3,"file":"reverse-grade.js","sourceRoot":"","sources":["../../src/curve/reverse-grade.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAgC;AAChC,yCAAyC;AACzC,MAAa,YAAa,SAAQ,aAAK;IACrC;;;;OAIG;IACH,OAAO,CAAC,GAAW;QACjB,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,GAAG,GAAG,CAAC;QAEd,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACxB,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACN,qDAAqD;YACrD,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;gBACxB,MAAM,GAAG,CAAC,CAAC;YACb,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;YACxE,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAxBD,oCAwBC"}
1
+ {"version":3,"file":"reverse-grade.js","sourceRoot":"","sources":["../../src/curve/reverse-grade.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAgC;AAChC;;;;GAIG;AACH,MAAa,YAAa,SAAQ,aAAK;IACrC;;;;OAIG;IACH,YAAY,EAAU,EAAE,EAAU;QAChC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACxB,CAAC;IACD;;;;OAIG;IACH,OAAO,CAAC,GAAW;QACjB,MAAM,CAAC,GAAG,GAAG,CAAC;QAEd,oEAAoE;QACpE,wEAAwE;QACxE,qEAAqE;QACrE,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;gBAAE,OAAO,CAAC,CAAC;YAC3B,OAAO,CAAC,CAAC,CAAC,SAAS;QACrB,CAAC;QAED,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;YAAE,OAAO,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;YAAE,OAAO,CAAC,CAAC;QAC3B,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AA7BD,oCA6BC"}
@@ -1,5 +1,6 @@
1
+ import { Fuzzifier } from './fuzzifier';
1
2
  /** Base class representing a Shape. */
2
- export declare abstract class Shape {
3
+ export declare abstract class Shape implements Fuzzifier {
3
4
  readonly x0: number;
4
5
  readonly x1: number;
5
6
  readonly x2: number;
@@ -1 +1 @@
1
- {"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/curve/shape.ts"],"names":[],"mappings":"AACA,uCAAuC;AACvC,8BAAsB,KAAK;IACzB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IAErB;;;;;;OAMG;gBACS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAmB1D;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CACtC"}
1
+ {"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/curve/shape.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,uCAAuC;AACvC,8BAAsB,KAAM,YAAW,SAAS;IAC9C,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAC;IAErB;;;;;;OAMG;gBACS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAmB1D;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CACtC"}
@@ -17,19 +17,19 @@ class Shape {
17
17
  constructor(x0, x1, x2, x3) {
18
18
  Object.defineProperty(this, 'x0', {
19
19
  value: x0,
20
- writable: false
20
+ writable: false,
21
21
  });
22
22
  Object.defineProperty(this, 'x1', {
23
23
  value: x1,
24
- writable: false
24
+ writable: false,
25
25
  });
26
26
  Object.defineProperty(this, 'x2', {
27
27
  value: x2,
28
- writable: false
28
+ writable: false,
29
29
  });
30
30
  Object.defineProperty(this, 'x3', {
31
31
  value: x3,
32
- writable: false
32
+ writable: false,
33
33
  });
34
34
  }
35
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"shape.js","sourceRoot":"","sources":["../../src/curve/shape.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,uCAAuC;AACvC,MAAsB,KAAK;IAChB,EAAE,CAAU;IACZ,EAAE,CAAU;IACZ,EAAE,CAAU;IACZ,EAAE,CAAU;IAErB;;;;;;OAM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,IAAI,EAAE;YAChC,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC;CAQF;AAtCD,sBAsCC"}
@@ -1,3 +1,4 @@
1
+ import { Fuzzifier } from './fuzzifier';
1
2
  /**
2
3
  * Class representing a Sigmoid.
3
4
  * @example
@@ -5,13 +6,15 @@
5
6
  * sigmoid = new Sigmoid(0, 100000);
6
7
  * sigmoid2.fuzzify(10);
7
8
  */
8
- export declare class Sigmoid {
9
+ export declare class Sigmoid implements Fuzzifier {
9
10
  private readonly center;
10
11
  private readonly slope;
11
12
  /**
12
13
  * Create a Sigmoid Function.
13
14
  * @param {number} center - The center point of the sigmoid curve (where it outputs 0.5)
14
- * @param {number} slope - The slope of the sigmoid curve (higher = steeper transition)
15
+ * @param {number} slope - Width of the transition: it appears in the denominator
16
+ * as 1 / (1 + exp(-(x - center) / slope)), so a smaller slope means a steeper
17
+ * transition and a larger slope a gentler one.
15
18
  */
16
19
  constructor(center?: number, slope?: number);
17
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sigmoid.d.ts","sourceRoot":"","sources":["../../src/curve/sigmoid.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B;;;;OAIG;gBACS,MAAM,GAAE,MAAU,EAAE,KAAK,GAAE,MAAU;IAIjD;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;CAS3B"}
1
+ {"version":3,"file":"sigmoid.d.ts","sourceRoot":"","sources":["../../src/curve/sigmoid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC;;;;;;GAMG;AACH,qBAAa,OAAQ,YAAW,SAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAE/B;;;;;;OAMG;gBACS,MAAM,GAAE,MAAU,EAAE,KAAK,GAAE,MAAU;IAIjD;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;CAS3B"}
@@ -14,7 +14,9 @@ class Sigmoid {
14
14
  /**
15
15
  * Create a Sigmoid Function.
16
16
  * @param {number} center - The center point of the sigmoid curve (where it outputs 0.5)
17
- * @param {number} slope - The slope of the sigmoid curve (higher = steeper transition)
17
+ * @param {number} slope - Width of the transition: it appears in the denominator
18
+ * as 1 / (1 + exp(-(x - center) / slope)), so a smaller slope means a steeper
19
+ * transition and a larger slope a gentler one.
18
20
  */
19
21
  constructor(center = 0, slope = 1) {
20
22
  this.center = center;
@@ -1 +1 @@
1
- {"version":3,"file":"sigmoid.js","sourceRoot":"","sources":["../../src/curve/sigmoid.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb;;;;;;GAMG;AACH,MAAa,OAAO;IACD,MAAM,CAAS;IACf,KAAK,CAAS;IAE/B;;;;OAIG;IACH,YAAY,SAAiB,CAAC,EAAE,QAAgB,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IACD;;;;OAIG;IACH,OAAO,CAAC,CAAS;QACf,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;YACrB,mDAAmD;YACnD,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM;gBAAE,OAAO,CAAC,CAAC;YAC9B,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM;gBAAE,OAAO,CAAC,CAAC;YAC9B,OAAO,GAAG,CAAC,CAAC,kBAAkB;QAChC,CAAC;QACD,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACjE,CAAC;CACF;AA3BD,0BA2BC"}
1
+ {"version":3,"file":"sigmoid.js","sourceRoot":"","sources":["../../src/curve/sigmoid.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb;;;;;;GAMG;AACH,MAAa,OAAO;IACD,MAAM,CAAS;IACf,KAAK,CAAS;IAE/B;;;;;;OAMG;IACH,YAAY,SAAiB,CAAC,EAAE,QAAgB,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IACD;;;;OAIG;IACH,OAAO,CAAC,CAAS;QACf,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;YACrB,mDAAmD;YACnD,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM;gBAAE,OAAO,CAAC,CAAC;YAC9B,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM;gBAAE,OAAO,CAAC,CAAC;YAC9B,OAAO,GAAG,CAAC,CAAC,kBAAkB;QAChC,CAAC;QACD,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACjE,CAAC;CACF;AA7BD,0BA6BC"}
@@ -36,16 +36,16 @@ class Trapezoid extends shape_1.Shape {
36
36
  else if (x >= this.x3) {
37
37
  result = 0;
38
38
  }
39
- else if ((x >= this.x1) && (x <= this.x2)) {
39
+ else if (x >= this.x1 && x <= this.x2) {
40
40
  result = 1;
41
41
  }
42
- else if ((x > this.x0) && (x < this.x1)) {
42
+ else if (x > this.x0 && x < this.x1) {
43
43
  // Handle case where x0 = x1 (vertical left edge)
44
44
  if (this.x1 === this.x0) {
45
45
  result = 1;
46
46
  }
47
47
  else {
48
- result = (x / (this.x1 - this.x0)) - (this.x0 / (this.x1 - this.x0));
48
+ result = x / (this.x1 - this.x0) - this.x0 / (this.x1 - this.x0);
49
49
  }
50
50
  }
51
51
  else {
@@ -54,7 +54,7 @@ class Trapezoid extends shape_1.Shape {
54
54
  result = 1;
55
55
  }
56
56
  else {
57
- result = (-x / (this.x3 - this.x2)) + (this.x3 / (this.x3 - this.x2));
57
+ result = -x / (this.x3 - this.x2) + this.x3 / (this.x3 - this.x2);
58
58
  }
59
59
  }
60
60
  return result;
@@ -1 +1 @@
1
- {"version":3,"file":"trapezoid.js","sourceRoot":"","sources":["../../src/curve/trapezoid.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AACb,mCAAgC;AAChC;;;;GAIG;AACH,MAAa,SAAU,SAAQ,aAAK;IAClC;;;;OAIG;IACH,OAAO,CAAC,GAAW;QACjB,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,GAAG,GAAG,CAAC;QAEd,yDAAyD;QACzD,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;YACtE,OAAO,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;QAED,4CAA4C;QAC5C,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;YAC/C,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE;gBAAE,OAAO,CAAC,CAAC;YAC1B,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE;gBAAE,OAAO,CAAC,CAAC;YAC3C,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE;gBAAE,OAAO,CAAC,CAAC;YAC1B,OAAO,CAAC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AAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;YACtC,iDAAiD;YACjD,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;gBACxB,MAAM,GAAG,CAAC,CAAC;YACb,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;aAAM,CAAC;YACN,kDAAkD;YAClD,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;gBACxB,MAAM,GAAG,CAAC,CAAC;YACb,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA9CD,8BA8CC"}
@@ -5,6 +5,13 @@ import { Shape } from './shape';
5
5
  * new Triangle(0, 10, 20)
6
6
  */
7
7
  export declare class Triangle extends Shape {
8
+ /**
9
+ * Create a Triangle.
10
+ * @param {number} x0 - left base point
11
+ * @param {number} x1 - peak
12
+ * @param {number} x2 - right base point
13
+ */
14
+ constructor(x0: number, x1: number, x2: number);
8
15
  /**
9
16
  * Fuzzify
10
17
  * @param {number} x - Point on X axis
@@ -1 +1 @@
1
- {"version":3,"file":"triangle.d.ts","sourceRoot":"","sources":["../../src/curve/triangle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;CAwC3B"}
1
+ {"version":3,"file":"triangle.d.ts","sourceRoot":"","sources":["../../src/curve/triangle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC;;;;;OAKG;gBACS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;IAG9C;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;CAwC3B"}