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.
Files changed (2) hide show
  1. package/dist/DLine.js +10 -13
  2. 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.begin.distance(this.end) / 2;
225
- const dcosT = td * Math.cos(fi);
226
- const dsinT = td * Math.sin(fi);
227
- const p1T = new DPoint_1.DPoint(p.x - dsinT, p.y - dcosT);
228
- const p2T = new DPoint_1.DPoint(p.x + dsinT, p.y + dcosT);
229
- const dcos = d * Math.cos(fi);
230
- const dsin = d * Math.sin(fi);
231
- const p2 = new DPoint_1.DPoint(p.x + dsin, p.y + dcos);
232
- const p3 = new DPoint_1.DPoint(p.x - dsin, p.y + dcos);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dgeoutils",
3
- "version": "2.2.18",
3
+ "version": "2.2.19",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "node_modules/.bin/tsc",