UNPKG

@zxing/library

Version:

TypeScript port of ZXing multi-format 1D/2D barcode image processing library.

37 lines (36 loc) 1.27 kB
/** * General math-related and numeric utility functions. */ export default class MathUtils { private constructor(); /** * Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its * argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut * differ slightly from {@link Math#round(float)} in that half rounds down for negative * values. -2.5 rounds to -3, not -2. For purposes here it makes no difference. * * @param d real value to round * @return nearest {@code int} */ static round(d: number): number; /** * @param aX point A x coordinate * @param aY point A y coordinate * @param bX point B x coordinate * @param bY point B y coordinate * @return Euclidean distance between points A and B */ static distance(aX: number, aY: number, bX: number, bY: number): number; /** * @param aX point A x coordinate * @param aY point A y coordinate * @param bX point B x coordinate * @param bY point B y coordinate * @return Euclidean distance between points A and B */ /** * @param array values to sum * @return sum of values in array */ static sum(array: Int32Array): number; }