@latticexyz/utils 0.9.0 → 0.10.0
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.
- package/CHANGELOG.md +6 -0
- package/package.json +2 -2
- package/src/distance.ts +10 -0
- package/src/index.ts +2 -0
- package/src/math.ts +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.10.0](https://github.com/latticexyz/mud/compare/v0.9.0...v0.10.0) (2022-09-14)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- matching Perlin noise implementations in Solidity and AssemblyScript ([#145](https://github.com/latticexyz/mud/issues/145)) ([29094c4](https://github.com/latticexyz/mud/commit/29094c4b0c3eeeacd3af690310c7de93a0c45e14))
|
|
11
|
+
|
|
6
12
|
# [0.9.0](https://github.com/latticexyz/mud/compare/v0.8.1...v0.9.0) (2022-09-13)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/utils",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"proxy-deep": "^3.1.1",
|
|
41
41
|
"rxjs": "^7.5.5"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "724f4545c36989b25e47046bfaa0903e9b8d4bab"
|
|
44
44
|
}
|
package/src/distance.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the Euclidean distance between two points
|
|
3
|
+
* https://en.wikipedia.org/wiki/Euclidean_distance
|
|
4
|
+
* @param a
|
|
5
|
+
* @param b
|
|
6
|
+
* @returns Euclidian distance between a and b
|
|
7
|
+
*/
|
|
8
|
+
export function euclidean(a: [number, number], b: [number, number]): number {
|
|
9
|
+
return Math.sqrt(Math.pow(a[0] - b[0], 2) + Math.pow(a[1] - b[1], 2));
|
|
10
|
+
}
|
package/src/index.ts
CHANGED
package/src/math.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For positive inputs: returns the greatest integer less than or equal to its numeric argument.
|
|
3
|
+
* For negative inputs: returns the smallest integer greater than or equal to its numeric argument.
|
|
4
|
+
*
|
|
5
|
+
* @param x A numeric expression.
|
|
6
|
+
* @returns Input rounded towards zero.
|
|
7
|
+
*/
|
|
8
|
+
export function roundTowardsZero(x: number) {
|
|
9
|
+
const sign = x < 0 ? -1 : 1;
|
|
10
|
+
return sign * Math.floor(Math.abs(x));
|
|
11
|
+
}
|