lisn.js
Version:
Simply handle user gestures and actions. Includes widgets.
1 lines • 23.2 kB
Source Map (JSON)
{"version":3,"file":"math.cjs","names":["MC","_interopRequireWildcard","require","MH","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","roundNumTo","value","numDecimal","multiplicationFactor","pow","round","exports","isValidNum","isNumber","NUMBER","isFinite","toNum","defaultValue","numValue","isLiteralString","parseFloat","toInt","floor","toNonNegNum","toPosNum","toNumWithBounds","limits","_limits$min","_limits$max","isDefaultGiven","undefined","min","max","result","_ref","maxAbs","values","map","v","abs","minAbs","havingMaxAbs","lengthOf","sort","a","b","INFINITY","havingMinAbs","hAngle","x","y","normalizeAngle","MATH","atan2","PI","degToRad","radToDeg","areParallel","vA","vB","angleDiffThreshold","angleA","angleB","areAntiParallel","distanceBetween","ptA","ptB","sqrt","quadraticRoots","c","z","easeInOutQuad","criticallyDamped","settings","lTarget","precision","lag","N","w0","l","dt","A","B","exp","sortedKeysByVal","obj","descending","keysOf","keyWithMaxVal","lastOf","keyWithMinVal","firstOf","getBitmask","start","end"],"sources":["../../../src/ts/utils/math.ts"],"sourcesContent":["/**\n * @module Utils\n */\n\nimport * as MC from \"@lisn/globals/minification-constants\";\nimport * as MH from \"@lisn/globals/minification-helpers\";\n\nimport { Point, Vector, AtLeastOne } from \"@lisn/globals/types\";\n\n/**\n * Round a number to the given decimal precision.\n *\n * @category Math\n */\nexport const roundNumTo = (value: number, numDecimal = 0) => {\n const multiplicationFactor = MH.pow(10, numDecimal);\n return MH.round(value * multiplicationFactor) / multiplicationFactor;\n};\n\n/**\n * Returns true if the given value is a valid _finite_ number.\n *\n * @category Validation\n */\nexport const isValidNum = (value: unknown): value is number =>\n MH.isNumber(value) && MC.NUMBER.isFinite(value);\n\n/**\n * If the given value is a valid _finite_ number, it is returned, otherwise\n * the default is returned.\n *\n * @category Math\n */\nexport const toNum = <D extends number | false | null = 0>(\n value: unknown,\n defaultValue: D | 0 = 0,\n): number | D => {\n const numValue = MH.isLiteralString(value) ? MH.parseFloat(value) : value;\n\n // parseFloat will strip trailing non-numeric characters, so we check that\n // the parsed number is equal to the string, if it was a string, using loose\n // equality, in order to make sure the entire string was a number.\n return isValidNum(numValue) && numValue == value ? numValue : defaultValue;\n};\n\n/**\n * If the given value is a valid _finite integer_ number, it is returned,\n * otherwise the default is returned.\n *\n * @category Math\n */\nexport const toInt = <D extends number | false | null = 0>(\n value: unknown,\n defaultValue: D | 0 = 0,\n): number | D => {\n let numValue = toNum(value, null);\n numValue = numValue === null ? numValue : MH.floor(numValue);\n\n // Ensure that the parsed int equaled the original by loose equality.\n return isValidNum(numValue) && numValue == value ? numValue : defaultValue;\n};\n\n/**\n * If the given value is a valid non-negative _finite_ number, it is returned,\n * otherwise the default is returned.\n *\n * @category Math\n */\nexport const toNonNegNum = <D extends number | false | null = 0>(\n value: unknown,\n defaultValue: D | 0 = 0,\n): number | D => {\n const numValue = toNum(value, null);\n return numValue !== null && numValue >= 0 ? numValue : defaultValue;\n};\n\n/**\n * If the given value is a valid positive number, it is returned, otherwise the\n * default is returned.\n *\n * @category Math\n */\nexport const toPosNum = <D extends number | false | null = 0>(\n value: unknown,\n defaultValue: D | 0 = 0,\n): number | D => {\n const numValue = toNum(value, null);\n return numValue !== null && numValue > 0 ? numValue : defaultValue;\n};\n\n/**\n * Returns the given number bound by min and/or max value.\n *\n * If the value is not a valid number, then `defaultValue` is returned if given\n * (_including if it is null_), otherwise `limits.min` if given and not null,\n * otherwise `limits.max` if given and not null, or finally 0.\n *\n * If the value is outside the bounds, then:\n * - if `defaultValue` is given, `defaultValue` is returned (_including if it\n * is null_)\n * - otherwise, the min or the max value (whichever one is violated) is\n * returned\n *\n * @category Math\n */\nexport const toNumWithBounds = <D extends number | false | null = number>(\n value: unknown,\n limits: AtLeastOne<{ min: number | null; max: number | null }>,\n defaultValue?: D,\n): number | D => {\n const isDefaultGiven = defaultValue !== undefined;\n const numValue = toNum(value, null);\n const min = limits?.min ?? null;\n const max = limits?.max ?? null;\n\n let result: number | D;\n if (!isValidNum(numValue)) {\n result = isDefaultGiven ? defaultValue : (min ?? max ?? 0);\n } else if (min !== null && numValue < min) {\n result = isDefaultGiven ? defaultValue : min;\n } else if (max !== null && numValue > max) {\n result = isDefaultGiven ? defaultValue : max;\n } else {\n result = numValue;\n }\n\n return result;\n};\n\n/**\n * Returns the largest absolute value among the given ones.\n *\n * The result is always positive.\n *\n * @category Math\n */\nexport const maxAbs = (...values: number[]) =>\n MH.max(...values.map((v) => MH.abs(v)));\n\n/**\n * Returns the smallest absolute value among the given ones.\n *\n * The result is always positive.\n *\n * @category Math\n */\nexport const minAbs = (...values: number[]) =>\n MH.min(...values.map((v) => MH.abs(v)));\n\n/**\n * Returns the value with the largest absolute value among the given ones.\n *\n * The result can be negative.\n *\n * @category Math\n */\nexport const havingMaxAbs = (...values: number[]): number =>\n MH.lengthOf(values)\n ? values.sort((a, b) => MH.abs(b) - MH.abs(a))[0]\n : -MC.INFINITY;\n\n/**\n * Returns the value with the smallest absolute value among the given ones.\n *\n * The result can be negative.\n *\n * @category Math\n */\nexport const havingMinAbs = (...values: number[]) =>\n MH.lengthOf(values)\n ? values.sort((a, b) => MH.abs(a) - MH.abs(b))[0]\n : MC.INFINITY;\n\n/**\n * Returns the angle (in radians) that the vector defined by the given x, y\n * makes with the positive horizontal axis.\n *\n * The angle returned is in the range -PI to PI, not including -PI.\n *\n * @category Math\n */\nexport const hAngle = (x: number, y: number) =>\n normalizeAngle(MC.MATH.atan2(y, x)); // ensure that -PI is transformed to +PI\n\n/**\n * Normalizes the given angle (in radians) so that it's in the range -PI to PI,\n * not including -PI.\n *\n * @category Math\n */\nexport const normalizeAngle = (a: number) => {\n // ensure it's positive in the range 0 to 2 PI\n while (a < 0 || a > MC.PI * 2) {\n a += (a < 0 ? 1 : -1) * MC.PI * 2;\n }\n\n // then, if > PI, offset by - 2PI\n return a > MC.PI ? a - MC.PI * 2 : a;\n};\n\n/**\n * Converts the given angle in degrees to radians.\n *\n * @category Math\n */\nexport const degToRad = (a: number) => (a * MC.PI) / 180;\n\n/**\n * Converts the given angle in radians to degrees.\n *\n * @category Math\n */\nexport const radToDeg = (a: number) => (a * 180) / MC.PI;\n\n/**\n * Returns true if the given vectors point in the same direction.\n *\n * @param angleDiffThreshold\n * Sets the threshold in degrees when comparing the angles of\n * two vectors. E.g. for 5 degrees threshold, directions\n * whose vectors are within 5 degrees of each other are\n * considered parallel.\n * It doesn't make sense for this value to be < 0 or >= 90\n * degrees. If it is, it's forced to be positive (absolute)\n * and <= 89.99.\n *\n * @category Math\n */\nexport const areParallel = (vA: Vector, vB: Vector, angleDiffThreshold = 0) => {\n const angleA = hAngle(vA[0], vA[1]);\n const angleB = hAngle(vB[0], vB[1]);\n angleDiffThreshold = MH.min(89.99, MH.abs(angleDiffThreshold));\n\n return (\n MH.abs(normalizeAngle(angleA - angleB)) <= degToRad(angleDiffThreshold)\n );\n};\n\n/**\n * Returns true if the given vectors point in the opposite direction.\n *\n * @param angleDiffThreshold\n * Sets the threshold in degrees when comparing the angles of\n * two vectors. E.g. for 5 degrees threshold, directions\n * whose vectors are within 175-185 degrees of each other are\n * considered antiparallel.\n * It doesn't make sense for this value to be < 0 or >= 90\n * degrees. If it is, it's forced to be positive (absolute)\n * and <= 89.99.\n *\n * @category Math\n */\nexport const areAntiParallel = (\n vA: Vector,\n vB: Vector,\n angleDiffThreshold = 0,\n) => areParallel(vA, [-vB[0], -vB[1]], angleDiffThreshold);\n\n/**\n * Returns the distance between two points on the screen.\n *\n * @category Math\n */\nexport const distanceBetween = (ptA: Point, ptB: Point) =>\n MH.sqrt(MH.pow(ptA[0] - ptB[0], 2) + MH.pow(ptA[1] - ptB[1], 2));\n\n/**\n * Returns the two roots of the quadratic equation with coefficients\n * `a`, `b` & `c`, i.e. `a * x^2 + b * x + c = 0`\n *\n * The roots may be `NaN` if the quadratic has no real solutions.\n *\n * @category Math\n */\nexport const quadraticRoots = (a: number, b: number, c: number) => {\n const z = MH.sqrt(b * b - 4 * a * c);\n return [(-b + z) / (2 * a), (-b - z) / (2 * a)];\n};\n\n/**\n * Returns the value that an \"easing\" quadratic function would have at the\n * given x.\n *\n * @see https://easings.net/#easeInOutQuad\n *\n * @param x Must be between 0 and 1.\n *\n * @returns The current y-axis value between 0 and 1.\n *\n * @category Math\n */\nexport const easeInOutQuad = (x: number) =>\n x < 0.5 ? 2 * x * x : 1 - MH.pow(-2 * x + 2, 2) / 2;\n\n/**\n * Returns the new position and velocity for a critically damped user-driven\n * spring state toward a current target position.\n *\n * @param [settings.lTarget] Target final position.\n * @param [settings.dt] Time step in milliseconds since the last call.\n * Must be small for the returned values to be\n * meaningful.\n * @param [settings.lag] Lag in milliseconds (how long it should take\n * for it to reach the final position). Must be\n * positive.\n * @param [settings.l = 0] Current position (starting or one returned by\n * previous call).\n * @param [settings.v = 0] Current velocity (returned by previous call).\n * @param [settings.precision = 2] Number of decimal places to round position to\n * in order to determine when it's \"done\".\n * @returns Updated position and velocity\n *\n * @since v1.2.0\n *\n * @category Math\n */\nexport const criticallyDamped = (settings: {\n lTarget: number;\n dt: number;\n lag: number;\n l?: number;\n v?: number;\n precision?: number;\n}) => {\n const { lTarget, precision = 2 } = settings;\n const lag = toNumWithBounds(settings.lag, { min: 1 }) / 1000; // to seconds\n\n // Since the position only approaches asymptotically the target it never truly\n // reaches it exactly we need an approximation to calculate w0. N determines\n // how far away from the target position we are after `lag` milliseconds.\n const N = 7;\n const w0 = N / lag;\n\n let { l = 0, v = 0, dt } = settings;\n dt /= 1000; // to seconds\n\n if (roundNumTo(l - lTarget, precision) === 0) {\n // we're done\n l = lTarget;\n v = 0;\n } else if (dt > 0) {\n const A = l - lTarget;\n const B = v + w0 * A;\n const e = MH.exp(-w0 * dt);\n\n l = lTarget + (A + B * dt) * e;\n v = (B - w0 * (A + B * dt)) * e;\n }\n\n return { l, v };\n};\n\n/**\n * Returns an array of object's keys sorted by the numeric value they hold.\n *\n * @category Math\n */\nexport const sortedKeysByVal = <T extends Record<string, number>>(\n obj: T,\n descending = false,\n): Array<keyof T> => {\n if (descending) {\n return MH.keysOf(obj).sort((x: keyof T, y: keyof T) => obj[y] - obj[x]);\n }\n\n return MH.keysOf(obj).sort((x: keyof T, y: keyof T) => obj[x] - obj[y]);\n};\n\n/**\n * Returns the key in the given object which holds the largest numeric value.\n *\n * If the object is empty, returns `undefined`.\n *\n * @category Math\n */\nexport const keyWithMaxVal = (\n obj: Record<string, number>,\n): string | undefined => {\n return MH.lastOf(sortedKeysByVal(obj));\n};\n\n/**\n * Returns the key in the given object which holds the smallest numeric value.\n *\n * If the object is empty, returns `undefined`.\n *\n * @category Math\n */\nexport const keyWithMinVal = (\n obj: Record<string, number>,\n): string | undefined => {\n return MH.firstOf(sortedKeysByVal(obj));\n};\n\n/**\n * Takes two integers and returns a bitmask that covers all values between\n * 1 << start and 1 << end, _including the starting and ending one_.\n *\n * If pStart > pEnd, they are reversed.\n *\n * getBitmask(start, start) always returns 1 << start\n * getBitmask(start, end) always returns same as getBitmask(end, start)\n *\n * @category Math\n */\nexport const getBitmask = (start: number, end: number): number =>\n start > end\n ? getBitmask(end, start)\n : (~0 >>> (32 - end - 1 + start)) << start;\n"],"mappings":";;;;;;AAIA,IAAAA,EAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,EAAA,GAAAF,uBAAA,CAAAC,OAAA;AAAyD,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,C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