dgeoutils 2.2.18 → 2.2.19
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/dist/DLine.js +10 -13
- package/package.json +1 -1
package/dist/DLine.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DLine = void 0;
|
|
4
4
|
const DPoint_1 = require("./DPoint");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
|
+
const DNumbers_1 = require("./DNumbers");
|
|
6
7
|
class DLine {
|
|
7
8
|
constructor(a, b, c, begin = DPoint_1.DPoint.zero(), end = DPoint_1.DPoint.zero()) {
|
|
8
9
|
this.a = a;
|
|
@@ -221,19 +222,15 @@ class DLine {
|
|
|
221
222
|
}
|
|
222
223
|
movePoint(p, d) {
|
|
223
224
|
const fi = this.findFi(new DLine(1, 0, 0));
|
|
224
|
-
const td = this.
|
|
225
|
-
const
|
|
226
|
-
const
|
|
227
|
-
const p1T =
|
|
228
|
-
const p2T =
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (this.inRange(p1T) || this.inRange(p2T)) {
|
|
234
|
-
return p2;
|
|
235
|
-
}
|
|
236
|
-
return p3;
|
|
225
|
+
const td = this.x(new DPoint_1.DPoint(1, 1)).distance(this.x(new DPoint_1.DPoint(2, 2))) / 2;
|
|
226
|
+
const sinCos = new DPoint_1.DPoint(Math.sin(fi), Math.cos(fi));
|
|
227
|
+
const dt = sinCos.clone().scale(td);
|
|
228
|
+
const p1T = p.clone().move(dt.clone().minus());
|
|
229
|
+
const p2T = p.clone().move(dt);
|
|
230
|
+
if (DNumbers_1.DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers_1.DNumbers.like(this.y(p2T).y, p2T.y)) {
|
|
231
|
+
return p.clone().move(sinCos.scale(d));
|
|
232
|
+
}
|
|
233
|
+
return p.clone().move(sinCos.scale(d).setX(({ x }) => -x));
|
|
237
234
|
}
|
|
238
235
|
findFi({ a, b }, delta = 1.0001) {
|
|
239
236
|
const { a: q, b: w } = this;
|