@mborecki/geo2d 0.5.2 → 0.6.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.
|
@@ -78,6 +78,12 @@ export class Vec2 {
|
|
|
78
78
|
return this;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
sub(v: Vec2): Vec2 {
|
|
82
|
+
this.x -= v.x;
|
|
83
|
+
this.y -= v.y;
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
|
|
81
87
|
eq(v: Vec2): boolean {
|
|
82
88
|
return this.x === v.x && this.y === v.y;
|
|
83
89
|
}
|
|
@@ -102,7 +108,11 @@ export class Vec2 {
|
|
|
102
108
|
throw new Error('Wrong Vec2 source');
|
|
103
109
|
}
|
|
104
110
|
|
|
105
|
-
static add(v1: Vec2, v2: Vec2) {
|
|
111
|
+
static add(v1: Vec2, v2: Vec2): Vec2 {
|
|
106
112
|
return new Vec2(v1.x + v2.x, v1.y + v2.y);
|
|
107
113
|
}
|
|
114
|
+
|
|
115
|
+
static sub(v1: Vec2, v2: Vec2): Vec2 {
|
|
116
|
+
return new Vec2(v1.x - v2.x, v1.y - v2.y);
|
|
117
|
+
}
|
|
108
118
|
}
|