@mborecki/geo2d 0.4.1 → 0.5.1

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mb-puzzle/grid",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "private": true,
5
5
  "description": "",
6
6
  "main": "./src/grid.ts",
@@ -73,7 +73,7 @@ export class Grid {
73
73
  new Vec2(0, 1),
74
74
  ]
75
75
 
76
- return dirs.map(d => d.add(v))
76
+ return dirs.map(d => Vec2.add(d,v))
77
77
  .filter(v => Grid.isInGrid(v, size));
78
78
  }
79
79
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mb-puzzle/vec2",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "private": true,
5
5
  "description": "",
6
6
  "main": "./src/vec2.ts",
@@ -44,7 +44,7 @@ export class Vec2 {
44
44
  }
45
45
 
46
46
  get size() {
47
- return Math.sqrt(this.x*this.x + this.y*this.y);
47
+ return Math.sqrt(this.x * this.x + this.y * this.y);
48
48
  }
49
49
 
50
50
  *[Symbol.iterator]() {
@@ -73,7 +73,8 @@ export class Vec2 {
73
73
  }
74
74
 
75
75
  add(v: Vec2): Vec2 {
76
- return new Vec2(this.x + v.x, this.y + v.y);
76
+ this.x += v.x;
77
+ this.y += v.y;
77
78
  }
78
79
 
79
80
  eq(v: Vec2): boolean {
@@ -99,4 +100,8 @@ export class Vec2 {
99
100
 
100
101
  throw new Error('Wrong Vec2 source');
101
102
  }
103
+
104
+ static add(v1: Vec2, v2: Vec2) {
105
+ return new Vec2(v1.x + v2.x, v1.y + v2.y);
106
+ }
102
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mborecki/geo2d",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "keywords": [],