@flighthq/math 0.3.1-next.425.a3192ab → 0.3.1-next.509.c235802

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.
@@ -2,11 +2,17 @@
2
2
  * Control-point distance, as a fraction of the radius, for approximating a quarter circle with one
3
3
  * cubic Bezier: `4 * (sqrt(2) - 1) / 3`.
4
4
  *
5
- * Named for the circle that defines it rather than the arcs that use it. It is computed rather than
6
- * written out because a transcribed decimal is a second copy of a number nothing recomputes — the
7
- * digits are long enough that a wrong one reads as correct and draws a circle that still looks round.
5
+ * Named for the circle that defines it rather than the arcs that use it. Written as a literal and
6
+ * pinned to that formula by the colocated test, which IS the recomputation a transcribed decimal
7
+ * would otherwise lack — the digits are long enough that a wrong one reads as correct and still
8
+ * draws a circle that looks round.
9
+ *
10
+ * A literal rather than the expression because `Math.SQRT2` is a property of a mutable global: no
11
+ * correct minifier may evaluate `4 * (Math.SQRT2 - 1) / 3` at build time, so that form reaches the
12
+ * bundle as a runtime computation of a compile-time-known number. Neither form is inlined at its
13
+ * use sites and both measure the same gzipped size, so this buys evaluation, not bytes.
8
14
  */
9
- export declare const CIRCLE_KAPPA: number;
15
+ export declare const CIRCLE_KAPPA = 0.5522847498307936;
10
16
  /** Smallest positive number distinguishable from zero in floating-point comparisons. */
11
17
  export declare const EPSILON = 0.000001;
12
18
  /** Full circle in radians (2π). Prefer `TAU` over `2 * Math.PI` for clarity. */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,QAA6B,CAAC;AAEvD,wFAAwF;AACxF,eAAO,MAAM,OAAO,WAAO,CAAC;AAE5B,gFAAgF;AAChF,eAAO,MAAM,GAAG,QAAc,CAAC;AAE/B,yBAAyB;AACzB,eAAO,MAAM,OAAO,QAAc,CAAC;AAEnC,wDAAwD;AACxD,eAAO,MAAM,UAAU,QAAgB,CAAC;AAExC,wDAAwD;AACxD,eAAO,MAAM,UAAU,QAAgB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,qBAAqB,CAAC;AAE/C,wFAAwF;AACxF,eAAO,MAAM,OAAO,WAAO,CAAC;AAE5B,gFAAgF;AAChF,eAAO,MAAM,GAAG,QAAc,CAAC;AAE/B,yBAAyB;AACzB,eAAO,MAAM,OAAO,QAAc,CAAC;AAEnC,wDAAwD;AACxD,eAAO,MAAM,UAAU,QAAgB,CAAC;AAExC,wDAAwD;AACxD,eAAO,MAAM,UAAU,QAAgB,CAAC"}
package/dist/constants.js CHANGED
@@ -2,11 +2,17 @@
2
2
  * Control-point distance, as a fraction of the radius, for approximating a quarter circle with one
3
3
  * cubic Bezier: `4 * (sqrt(2) - 1) / 3`.
4
4
  *
5
- * Named for the circle that defines it rather than the arcs that use it. It is computed rather than
6
- * written out because a transcribed decimal is a second copy of a number nothing recomputes — the
7
- * digits are long enough that a wrong one reads as correct and draws a circle that still looks round.
5
+ * Named for the circle that defines it rather than the arcs that use it. Written as a literal and
6
+ * pinned to that formula by the colocated test, which IS the recomputation a transcribed decimal
7
+ * would otherwise lack — the digits are long enough that a wrong one reads as correct and still
8
+ * draws a circle that looks round.
9
+ *
10
+ * A literal rather than the expression because `Math.SQRT2` is a property of a mutable global: no
11
+ * correct minifier may evaluate `4 * (Math.SQRT2 - 1) / 3` at build time, so that form reaches the
12
+ * bundle as a runtime computation of a compile-time-known number. Neither form is inlined at its
13
+ * use sites and both measure the same gzipped size, so this buys evaluation, not bytes.
8
14
  */
9
- export const CIRCLE_KAPPA = (4 * (Math.SQRT2 - 1)) / 3;
15
+ export const CIRCLE_KAPPA = 0.5522847498307936;
10
16
  /** Smallest positive number distinguishable from zero in floating-point comparisons. */
11
17
  export const EPSILON = 1e-6;
12
18
  /** Full circle in radians (2π). Prefer `TAU` over `2 * Math.PI` for clarity. */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEvD,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC;AAE5B,gFAAgF;AAChF,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAE/B,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAEnC,wDAAwD;AACxD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAExC,wDAAwD;AACxD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE/C,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC;AAE5B,gFAAgF;AAChF,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAE/B,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAEnC,wDAAwD;AACxD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAExC,wDAAwD;AACxD,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/math",
3
- "version": "0.3.1-next.425.a3192ab",
3
+ "version": "0.3.1-next.509.c235802",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@flighthq/types": "0.3.1-next.425.a3192ab"
41
+ "@flighthq/types": "0.3.1-next.509.c235802"
42
42
  },
43
43
  "devDependencies": {
44
44
  "typescript": "^5.3.0"
@@ -6,6 +6,12 @@ describe('constants', () => {
6
6
  // digits agrees with a typo in them, which is how a wrong digit at the 13th decimal survived a
7
7
  // full suite. Exact equality, not toBeCloseTo: the error this guards against is far smaller than
8
8
  // any tolerance worth writing.
9
+ //
10
+ // MEASURED, not assumed: mutating the constant's 13th decimal from ...36 to ...46 and running
11
+ // the whole repository fails exactly ONE test of 17,045 — this one. The sweep below passes over
12
+ // the wrong digit, as does every path, shape and clip test. That is the entire case for pinning
13
+ // a literal to its formula here rather than trusting geometry to notice, and it is why the
14
+ // original wrong digit survived a full suite.
9
15
  it('equals four thirds of the square root of two less one', () => {
10
16
  expect(CIRCLE_KAPPA).toBe((4 * (Math.sqrt(2) - 1)) / 3);
11
17
  });