@here/harp-utils
Advanced tools
+30
-0
@@ -0,1 +1,5 @@ | ||
| interface Vec2Like { | ||
| x: number; | ||
| y: number; | ||
| } | ||
| export declare namespace Math2D { | ||
@@ -31,2 +35,8 @@ /** | ||
| /** | ||
| * Copy values from another box. | ||
| * | ||
| * @param box - Another box. | ||
| */ | ||
| copy(box: Box): void; | ||
| /** | ||
| * Test box for inclusion of point. | ||
@@ -107,3 +117,23 @@ * | ||
| } | undefined; | ||
| /** | ||
| * Computes the intersection point between two lines. | ||
| * | ||
| * @remarks | ||
| * This functions computes the | ||
| * {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection | ||
| * | line-line intersection} of two lines given two points on each line. | ||
| * | ||
| * @param x1 - x coordinate of the first point of the first line. | ||
| * @param y1 - y coordinate of the first point of the first line. | ||
| * @param x2 - x coordinate of the second point of the first line. | ||
| * @param y2 - y coordinate of the second point of the first line. | ||
| * @param x3 - x coordinate of the first point of the second line. | ||
| * @param y3 - y coordinate of the first point of the second line. | ||
| * @param x4 - x coordinate of the second point of the second line. | ||
| * @param y4 - y coordinate of the second point of the second line. | ||
| * @param result - The resulting point. | ||
| */ | ||
| function intersectLines(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, result?: Vec2Like): Vec2Like | undefined; | ||
| } | ||
| export {}; | ||
| //# sourceMappingURL=Math2D.d.ts.map |
+41
-0
@@ -46,2 +46,13 @@ "use strict"; | ||
| /** | ||
| * Copy values from another box. | ||
| * | ||
| * @param box - Another box. | ||
| */ | ||
| copy(box) { | ||
| this.x = box.x; | ||
| this.y = box.y; | ||
| this.w = box.w; | ||
| this.h = box.h; | ||
| } | ||
| /** | ||
| * Test box for inclusion of point. | ||
@@ -192,3 +203,33 @@ * | ||
| Math2D.intersectLineAndCircle = intersectLineAndCircle; | ||
| /** | ||
| * Computes the intersection point between two lines. | ||
| * | ||
| * @remarks | ||
| * This functions computes the | ||
| * {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection | ||
| * | line-line intersection} of two lines given two points on each line. | ||
| * | ||
| * @param x1 - x coordinate of the first point of the first line. | ||
| * @param y1 - y coordinate of the first point of the first line. | ||
| * @param x2 - x coordinate of the second point of the first line. | ||
| * @param y2 - y coordinate of the second point of the first line. | ||
| * @param x3 - x coordinate of the first point of the second line. | ||
| * @param y3 - y coordinate of the first point of the second line. | ||
| * @param x4 - x coordinate of the second point of the second line. | ||
| * @param y4 - y coordinate of the second point of the second line. | ||
| * @param result - The resulting point. | ||
| */ | ||
| function intersectLines(x1, y1, x2, y2, x3, y3, x4, y4, result = { x: 0, y: 0 }) { | ||
| const d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4); | ||
| if (d === 0) { | ||
| return undefined; | ||
| } | ||
| const px = ((x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4)) / d; | ||
| const py = ((x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4)) / d; | ||
| result.x = px; | ||
| result.y = py; | ||
| return result; | ||
| } | ||
| Math2D.intersectLines = intersectLines; | ||
| })(Math2D = exports.Math2D || (exports.Math2D = {})); | ||
| //# sourceMappingURL=Math2D.js.map |
+0
-13
@@ -13,15 +13,2 @@ export declare namespace MathUtils { | ||
| /** | ||
| * Returns a linear interpolation between the values of edge0 and edge1 based on the factor. | ||
| * | ||
| * Given two known points the linear interpolant between these points may be presented as | ||
| * straight line. This means that for given factor change the resulting change of return | ||
| * value is always const. | ||
| * @see https://en.wikipedia.org/wiki/Linear_interpolation | ||
| * | ||
| * @param edge0 - | ||
| * @param edge1 - | ||
| * @param factor - Interpolation factor that ranges between: 0 <= x <= 1. | ||
| */ | ||
| function lerp(edge0: number, edge1: number, factor: number): number; | ||
| /** | ||
| * Returns a smooth interpolation between the values edge0 and edge1 based on the interpolation | ||
@@ -28,0 +15,0 @@ * factor x. `0 <= x <= 1`. |
+0
-16
@@ -25,18 +25,2 @@ "use strict"; | ||
| /** | ||
| * Returns a linear interpolation between the values of edge0 and edge1 based on the factor. | ||
| * | ||
| * Given two known points the linear interpolant between these points may be presented as | ||
| * straight line. This means that for given factor change the resulting change of return | ||
| * value is always const. | ||
| * @see https://en.wikipedia.org/wiki/Linear_interpolation | ||
| * | ||
| * @param edge0 - | ||
| * @param edge1 - | ||
| * @param factor - Interpolation factor that ranges between: 0 <= x <= 1. | ||
| */ | ||
| function lerp(edge0, edge1, factor) { | ||
| return edge0 * (1 - factor) + edge1 * factor; | ||
| } | ||
| MathUtils.lerp = lerp; | ||
| /** | ||
| * Returns a smooth interpolation between the values edge0 and edge1 based on the interpolation | ||
@@ -43,0 +27,0 @@ * factor x. `0 <= x <= 1`. |
+2
-2
| { | ||
| "name": "@here/harp-utils", | ||
| "version": "0.20.0", | ||
| "version": "0.21.0", | ||
| "description": "Provides utilities: logging, debugging.", | ||
@@ -36,3 +36,3 @@ "main": "index.js", | ||
| }, | ||
| "gitHead": "862a06f6632e930e77208a7dc24bb293f826524a" | ||
| "gitHead": "460af4b155d303d96cb69152cbdbc3ff4c72213e" | ||
| } |
116833
1.47%2936
1.45%