From d8b31be098172ef6ca6b966e65552caf5262d2da Mon Sep 17 00:00:00 2001 From: VsevolodX Date: Fri, 13 Mar 2026 19:19:48 -0700 Subject: [PATCH] update: fix tolerance for points at edges --- dist/js/properties/non-scalar/BandStructureProperty.d.ts | 2 +- dist/js/properties/non-scalar/BandStructureProperty.js | 4 ++-- src/js/properties/non-scalar/BandStructureProperty.ts | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/dist/js/properties/non-scalar/BandStructureProperty.d.ts b/dist/js/properties/non-scalar/BandStructureProperty.d.ts index be7bae4..ef42218 100644 --- a/dist/js/properties/non-scalar/BandStructureProperty.d.ts +++ b/dist/js/properties/non-scalar/BandStructureProperty.d.ts @@ -27,7 +27,7 @@ export declare class BandStructureConfig extends HighChartsConfig { }); cleanXDataArray(rawData?: XDataArray): XDataArrayNested; calculatePointsDistance(listOfPoints?: XDataArrayNested): number[]; - findSymmetryPointIndex(xDataArray: XDataArrayNested, point: number[]): number; + findSymmetryPointIndex(xDataArray: XDataArrayNested, point: number[], tolerance?: number): number; plotXLines(): PlotLines[]; plotXLineAtPoint({ point, distance }: { point: string; diff --git a/dist/js/properties/non-scalar/BandStructureProperty.js b/dist/js/properties/non-scalar/BandStructureProperty.js index 63a1e3d..d04133a 100644 --- a/dist/js/properties/non-scalar/BandStructureProperty.js +++ b/dist/js/properties/non-scalar/BandStructureProperty.js @@ -53,8 +53,8 @@ class BandStructureConfig extends highcharts_1.HighChartsConfig { }); } // find index of a point inside an array of points - findSymmetryPointIndex(xDataArray, point) { - return xDataArray.findIndex((p) => math_1.math.vDist(p, point) === 0); + findSymmetryPointIndex(xDataArray, point, tolerance = 10 ** -exports._POINT_COORDINATES_PRECISION_) { + return xDataArray.findIndex((p) => math_1.math.vEqualWithTolerance(p, point, tolerance)); } // create config for vertical lines at high symmetry points plotXLines() { diff --git a/src/js/properties/non-scalar/BandStructureProperty.ts b/src/js/properties/non-scalar/BandStructureProperty.ts index deee557..ce2ccaf 100644 --- a/src/js/properties/non-scalar/BandStructureProperty.ts +++ b/src/js/properties/non-scalar/BandStructureProperty.ts @@ -92,8 +92,12 @@ export class BandStructureConfig extends HighChartsConfig { } // find index of a point inside an array of points - findSymmetryPointIndex(xDataArray: XDataArrayNested, point: number[]) { - return xDataArray.findIndex((p) => codeJSMath.vDist(p, point) === 0); + findSymmetryPointIndex( + xDataArray: XDataArrayNested, + point: number[], + tolerance = 10 ** -_POINT_COORDINATES_PRECISION_, + ): number { + return xDataArray.findIndex((p) => codeJSMath.vEqualWithTolerance(p, point, tolerance)); } // create config for vertical lines at high symmetry points