@equinor/esv-intersection 3.1.9 → 4.1.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.
Files changed (97) hide show
  1. package/dist/components/axis.d.ts.map +1 -1
  2. package/dist/control/ExtendedCurveInterpolator.d.ts.map +1 -1
  3. package/dist/control/IntersectionReferenceSystem.d.ts.map +1 -1
  4. package/dist/control/LayerManager.d.ts.map +1 -1
  5. package/dist/control/MainController.d.ts.map +1 -1
  6. package/dist/control/ZoomPanHandler.d.ts.map +1 -1
  7. package/dist/control/overlay.d.ts.map +1 -1
  8. package/dist/datautils/colortable.d.ts.map +1 -1
  9. package/dist/datautils/findsample.d.ts.map +1 -1
  10. package/dist/datautils/picks.d.ts.map +1 -1
  11. package/dist/datautils/schematicShapeGenerator.d.ts +10 -10
  12. package/dist/datautils/schematicShapeGenerator.d.ts.map +1 -1
  13. package/dist/datautils/seismicimage.d.ts.map +1 -1
  14. package/dist/datautils/surfacedata.d.ts.map +1 -1
  15. package/dist/datautils/trajectory.d.ts.map +1 -1
  16. package/dist/index.cjs +2 -2
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.mjs +2533 -1570
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/index.umd.js +2 -2
  21. package/dist/index.umd.js.map +1 -1
  22. package/dist/layers/CalloutCanvasLayer.d.ts.map +1 -1
  23. package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts +2 -3
  24. package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts.map +1 -1
  25. package/dist/layers/CustomDisplayObjects/ComplexRopeGeometry.d.ts.map +1 -1
  26. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts +3 -4
  27. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts.map +1 -1
  28. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts +4 -4
  29. package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts.map +1 -1
  30. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts +3 -4
  31. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts.map +1 -1
  32. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts +4 -4
  33. package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts.map +1 -1
  34. package/dist/layers/GeomodelCanvasLayer.d.ts.map +1 -1
  35. package/dist/layers/GeomodelLabelsLayer.d.ts.map +1 -1
  36. package/dist/layers/GeomodelLayerV2.d.ts.map +1 -1
  37. package/dist/layers/GridLayer.d.ts.map +1 -1
  38. package/dist/layers/ImageCanvasLayer.d.ts.map +1 -1
  39. package/dist/layers/ReferenceLineLayer.d.ts.map +1 -1
  40. package/dist/layers/SchematicLayer.d.ts +6 -6
  41. package/dist/layers/SchematicLayer.d.ts.map +1 -1
  42. package/dist/layers/WellborePathLayer.d.ts.map +1 -1
  43. package/dist/layers/base/CanvasLayer.d.ts.map +1 -1
  44. package/dist/layers/base/HTMLLayer.d.ts.map +1 -1
  45. package/dist/layers/base/Layer.d.ts.map +1 -1
  46. package/dist/layers/base/PixiLayer.d.ts +7 -8
  47. package/dist/layers/base/PixiLayer.d.ts.map +1 -1
  48. package/dist/layers/base/SVGLayer.d.ts.map +1 -1
  49. package/dist/layers/schematicInterfaces.d.ts.map +1 -1
  50. package/dist/utils/arc-length.d.ts.map +1 -1
  51. package/dist/utils/root-finder.d.ts.map +1 -1
  52. package/dist/utils/text.d.ts.map +1 -1
  53. package/dist/utils/vectorUtils.d.ts +6 -6
  54. package/dist/utils/vectorUtils.d.ts.map +1 -1
  55. package/dist/vendor/pixi-dashed-line/index.d.ts +13 -13
  56. package/dist/vendor/pixi-dashed-line/index.d.ts.map +1 -1
  57. package/package.json +4 -6
  58. package/src/components/axis.ts +40 -10
  59. package/src/control/ExtendedCurveInterpolator.ts +47 -9
  60. package/src/control/IntersectionReferenceSystem.ts +110 -30
  61. package/src/control/LayerManager.ts +76 -24
  62. package/src/control/MainController.ts +37 -8
  63. package/src/control/ZoomPanHandler.ts +76 -14
  64. package/src/control/overlay.ts +18 -6
  65. package/src/datautils/colortable.ts +7 -2
  66. package/src/datautils/findsample.ts +12 -2
  67. package/src/datautils/picks.ts +66 -18
  68. package/src/datautils/schematicShapeGenerator.ts +591 -165
  69. package/src/datautils/seismicimage.ts +36 -10
  70. package/src/datautils/surfacedata.ts +119 -40
  71. package/src/datautils/trajectory.ts +56 -17
  72. package/src/layers/CalloutCanvasLayer.ts +129 -26
  73. package/src/layers/CustomDisplayObjects/ComplexRope.ts +11 -13
  74. package/src/layers/CustomDisplayObjects/ComplexRopeGeometry.ts +14 -13
  75. package/src/layers/CustomDisplayObjects/FixedWidthSimpleRope.ts +11 -14
  76. package/src/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.ts +13 -12
  77. package/src/layers/CustomDisplayObjects/UniformTextureStretchRope.ts +16 -17
  78. package/src/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.ts +11 -11
  79. package/src/layers/GeomodelCanvasLayer.ts +10 -3
  80. package/src/layers/GeomodelLabelsLayer.ts +212 -87
  81. package/src/layers/GeomodelLayerV2.ts +11 -7
  82. package/src/layers/GridLayer.ts +14 -3
  83. package/src/layers/ImageCanvasLayer.ts +17 -3
  84. package/src/layers/ReferenceLineLayer.ts +31 -9
  85. package/src/layers/SchematicLayer.ts +533 -173
  86. package/src/layers/WellborePathLayer.ts +22 -7
  87. package/src/layers/base/CanvasLayer.ts +18 -4
  88. package/src/layers/base/HTMLLayer.ts +11 -3
  89. package/src/layers/base/Layer.ts +10 -2
  90. package/src/layers/base/PixiLayer.ts +36 -43
  91. package/src/layers/base/SVGLayer.ts +13 -3
  92. package/src/layers/schematicInterfaces.ts +16 -6
  93. package/src/utils/arc-length.ts +31 -5
  94. package/src/utils/root-finder.ts +32 -4
  95. package/src/utils/text.ts +34 -7
  96. package/src/utils/vectorUtils.ts +27 -10
  97. package/src/vendor/pixi-dashed-line/index.ts +93 -39
@@ -23,7 +23,14 @@ export class Axis {
23
23
  private _flipY = false;
24
24
  private visible = true;
25
25
 
26
- constructor(mainGroup: Axis['mainGroup'], showLabels = true, labelXDesc: string, labelYDesc: string, unitOfMeasure: string, options?: Options) {
26
+ constructor(
27
+ mainGroup: Axis['mainGroup'],
28
+ showLabels = true,
29
+ labelXDesc: string,
30
+ labelYDesc: string,
31
+ unitOfMeasure: string,
32
+ options?: Options,
33
+ ) {
27
34
  this.mainGroup = mainGroup;
28
35
  this._showLabels = showLabels;
29
36
  this._labelXDesc = labelXDesc;
@@ -45,11 +52,17 @@ export class Axis {
45
52
  }
46
53
 
47
54
  private renderLabelx(): Selection<SVGTextElement, unknown, null, undefined> {
48
- const { _labelXDesc: labelXDesc, _unitOfMeasure: unitOfMeasure, _showLabels, _scaleX: scaleX } = this;
55
+ const {
56
+ _labelXDesc: labelXDesc,
57
+ _unitOfMeasure: unitOfMeasure,
58
+ _showLabels,
59
+ _scaleX: scaleX,
60
+ } = this;
49
61
  const [, width] = scaleX.range();
50
62
  const gx = this.renderGx();
51
63
 
52
- let labelx: Selection<SVGTextElement, unknown, null, undefined> = gx.select('text.axis-labelx');
64
+ let labelx: Selection<SVGTextElement, unknown, null, undefined> =
65
+ gx.select('text.axis-labelx');
53
66
  if (_showLabels) {
54
67
  if (labelx.empty()) {
55
68
  labelx = gx
@@ -69,11 +82,17 @@ export class Axis {
69
82
  }
70
83
 
71
84
  private renderLabely(): Selection<SVGTextElement, unknown, null, undefined> {
72
- const { _labelYDesc: labelYDesc, _unitOfMeasure: unitOfMeasure, _showLabels, _scaleY } = this;
85
+ const {
86
+ _labelYDesc: labelYDesc,
87
+ _unitOfMeasure: unitOfMeasure,
88
+ _showLabels,
89
+ _scaleY,
90
+ } = this;
73
91
  const [, height] = _scaleY.range();
74
92
  const gy = this.renderGy();
75
93
 
76
- let labely: Selection<SVGTextElement, unknown, null, undefined> = gy.select('text.axis-labely');
94
+ let labely: Selection<SVGTextElement, unknown, null, undefined> =
95
+ gy.select('text.axis-labely');
77
96
  if (_showLabels) {
78
97
  if (labely.empty()) {
79
98
  labely = gy
@@ -94,7 +113,10 @@ export class Axis {
94
113
 
95
114
  private renderGy(): Selection<SVGGElement, unknown, null, undefined> {
96
115
  const { _scaleX, _scaleY } = this;
97
- const yAxis = axisRight(_scaleY) as (selection: Selection<SVGGElement, unknown, null, undefined>, ...args: unknown[]) => void;
116
+ const yAxis = axisRight(_scaleY) as (
117
+ selection: Selection<SVGGElement, unknown, null, undefined>,
118
+ ...args: unknown[]
119
+ ) => void;
98
120
  const [, width] = _scaleX.range();
99
121
  const gy = this.createOrGet('y-axis');
100
122
  gy.call(yAxis);
@@ -105,7 +127,10 @@ export class Axis {
105
127
 
106
128
  private renderGx(): Selection<SVGGElement, unknown, null, undefined> {
107
129
  const { _scaleX, _scaleY } = this;
108
- const xAxis = axisBottom(_scaleX) as (selection: Selection<SVGGElement, unknown, null, undefined>, ...args: unknown[]) => void;
130
+ const xAxis = axisBottom(_scaleX) as (
131
+ selection: Selection<SVGGElement, unknown, null, undefined>,
132
+ ...args: unknown[]
133
+ ) => void;
109
134
  const [, height] = _scaleY.range();
110
135
 
111
136
  const gx = this.createOrGet('x-axis');
@@ -114,9 +139,12 @@ export class Axis {
114
139
  return gx;
115
140
  }
116
141
 
117
- private createOrGet = (name: string): Selection<SVGGElement, unknown, null, undefined> => {
142
+ private createOrGet = (
143
+ name: string,
144
+ ): Selection<SVGGElement, unknown, null, undefined> => {
118
145
  const { mainGroup } = this;
119
- let res: Selection<SVGGElement, unknown, null, undefined> = mainGroup.select(`g.${name}`);
146
+ let res: Selection<SVGGElement, unknown, null, undefined> =
147
+ mainGroup.select(`g.${name}`);
120
148
  if (res.empty()) {
121
149
  res = mainGroup.append('g').attr('class', name);
122
150
  }
@@ -129,7 +157,9 @@ export class Axis {
129
157
  }
130
158
 
131
159
  onResize(event: OnResizeEvent): void {
132
- this.mainGroup.attr('height', `${event.height}px`).attr('width', `${event.width}px`);
160
+ this.mainGroup
161
+ .attr('height', `${event.height}px`)
162
+ .attr('width', `${event.width}px`);
133
163
  }
134
164
 
135
165
  onRescale(event: OnRescaleEvent): void {
@@ -30,7 +30,14 @@ export class ExtendedCurveInterpolator extends CurveInterpolator {
30
30
  * @param {Number} tolerance Tolerance for result
31
31
  * @param {Number} iterations Max number of iterations to use
32
32
  */
33
- findTForArcLength(arcLength: number, options?: { approxT?: boolean; quickT?: boolean; normalizedLength?: number }): number {
33
+ findTForArcLength(
34
+ arcLength: number,
35
+ options?: {
36
+ approxT?: boolean;
37
+ quickT?: boolean;
38
+ normalizedLength?: number;
39
+ },
40
+ ): number {
34
41
  // TODO: Ideally the CurveInterpolator should be able to provide t for curve length
35
42
  let t;
36
43
  if (options?.approxT) {
@@ -49,14 +56,23 @@ export class ExtendedCurveInterpolator extends CurveInterpolator {
49
56
  * @param {Number} tolerance Tolerance for result
50
57
  * @param {Number} iterations Max number of iterations to use
51
58
  */
52
- findTByRootForArcLength(arcLength: number, tolerance = 0.01, iterations = 100): number {
59
+ findTByRootForArcLength(
60
+ arcLength: number,
61
+ tolerance = 0.01,
62
+ iterations = 100,
63
+ ): number {
53
64
  if (arcLength <= 0) {
54
65
  return 0.0;
55
66
  }
56
67
  if (arcLength >= this.length) {
57
68
  return 1.0;
58
69
  }
59
- const t = RootFinder.findRoot((x) => arcLength - this.getQuickArcLength(0, x), tolerance, iterations, arcLength / this.length);
70
+ const t = RootFinder.findRoot(
71
+ x => arcLength - this.getQuickArcLength(0, x),
72
+ tolerance,
73
+ iterations,
74
+ arcLength / this.length,
75
+ );
60
76
  return t;
61
77
  }
62
78
 
@@ -64,7 +80,10 @@ export class ExtendedCurveInterpolator extends CurveInterpolator {
64
80
  * Function which finds t value for arc length by simple approximation
65
81
  * @param {Number} arcLength Target arclength
66
82
  */
67
- findApproxTForArcLength(arcLength: number, normalizedLength?: number): number {
83
+ findApproxTForArcLength(
84
+ arcLength: number,
85
+ normalizedLength?: number,
86
+ ): number {
68
87
  const t = arcLength / (normalizedLength || this.length);
69
88
  return t;
70
89
  }
@@ -80,7 +99,8 @@ export class ExtendedCurveInterpolator extends CurveInterpolator {
80
99
  const index = BinarySearch.search(this.arcLengthLookup, arcLength);
81
100
  const v1 = this.arcLengthLookup[index]!;
82
101
  const v2 = this.arcLengthLookup[index + 1]!;
83
- const t = (index + (arcLength - v1) / (v2 - v1)) / this.arcLengthLookup.length;
102
+ const t =
103
+ (index + (arcLength - v1) / (v2 - v1)) / this.arcLengthLookup.length;
84
104
  return t;
85
105
  }
86
106
 
@@ -106,7 +126,12 @@ export class ExtendedCurveInterpolator extends CurveInterpolator {
106
126
  return this.length;
107
127
  }
108
128
  const tolerance = 0.002;
109
- return ArcLength.bisect((t: number) => this.getPointAt(t), from, to, tolerance);
129
+ return ArcLength.bisect(
130
+ (t: number) => this.getPointAt(t),
131
+ from,
132
+ to,
133
+ tolerance,
134
+ );
110
135
  }
111
136
 
112
137
  /**
@@ -125,14 +150,20 @@ export class ExtendedCurveInterpolator extends CurveInterpolator {
125
150
  const fromIndex = Math.floor(from * this.arcLengthLookup.length);
126
151
  const fromLl = this.arcLengthLookup[fromIndex]!;
127
152
  const fromLh = this.arcLengthLookup[fromIndex + 1]!;
128
- fromLength = fromLl + ((from * this.arcLengthLookup.length) % this.arcLengthLookup.length) * (fromLh - fromLl);
153
+ fromLength =
154
+ fromLl +
155
+ ((from * this.arcLengthLookup.length) % this.arcLengthLookup.length) *
156
+ (fromLh - fromLl);
129
157
  }
130
158
 
131
159
  if (to !== 1) {
132
160
  const toIndex = Math.floor(to * this.arcLengthLookup.length);
133
161
  const toLl = this.arcLengthLookup[toIndex]!;
134
162
  const toLh = this.arcLengthLookup[toIndex + 1]!;
135
- toLength = toLl + ((from * this.arcLengthLookup.length) % this.arcLengthLookup.length) * (toLh - toLl);
163
+ toLength =
164
+ toLl +
165
+ ((from * this.arcLengthLookup.length) % this.arcLengthLookup.length) *
166
+ (toLh - toLl);
136
167
  }
137
168
 
138
169
  const totalLength = toLength - fromLength;
@@ -143,7 +174,14 @@ export class ExtendedCurveInterpolator extends CurveInterpolator {
143
174
  * Function getting a point at curve length.
144
175
  * @param {Number} arcLength
145
176
  */
146
- getPointAtArcLength(arcLength: number, options?: { approxT?: boolean; quickT?: boolean; normalizedLength?: number }): Vector {
177
+ getPointAtArcLength(
178
+ arcLength: number,
179
+ options?: {
180
+ approxT?: boolean;
181
+ quickT?: boolean;
182
+ normalizedLength?: number;
183
+ },
184
+ ): Vector {
147
185
  const t = this.findTForArcLength(arcLength, options);
148
186
  return this.getPointAt(t);
149
187
  }
@@ -77,9 +77,13 @@ export class IntersectionReferenceSystem {
77
77
  this.getTrajectory = this.getTrajectory.bind(this);
78
78
  }
79
79
 
80
- private setPath(path: number[][], options: ReferenceSystemOptions = {}): void {
80
+ private setPath(
81
+ path: number[][],
82
+ options: ReferenceSystemOptions = {},
83
+ ): void {
81
84
  this.options = { ...defaultOptions, ...options };
82
- const { arcDivisions, tension, calculateDisplacementFromBottom } = this.options;
85
+ const { arcDivisions, tension, calculateDisplacementFromBottom } =
86
+ this.options;
83
87
 
84
88
  this.path = path;
85
89
 
@@ -94,11 +98,17 @@ export class IntersectionReferenceSystem {
94
98
  options.trajectoryInterpolator ||
95
99
  new ExtendedCurveInterpolator(
96
100
  path.map((d: number[]) => [d[0]!, d[1]!]),
97
- { tension: tension || TENSION, arcDivisions: arcDivisions || ARC_DIVISIONS },
101
+ {
102
+ tension: tension || TENSION,
103
+ arcDivisions: arcDivisions || ARC_DIVISIONS,
104
+ },
98
105
  ),
99
106
  curtain:
100
107
  options.curtainInterpolator ||
101
- new ExtendedCurveInterpolator(this.projectedPath, { tension: tension || TENSION, arcDivisions: arcDivisions || ARC_DIVISIONS }),
108
+ new ExtendedCurveInterpolator(this.projectedPath, {
109
+ tension: tension || TENSION,
110
+ arcDivisions: arcDivisions || ARC_DIVISIONS,
111
+ }),
102
112
  };
103
113
 
104
114
  const trajVector = this.getTrajectoryVector();
@@ -122,7 +132,13 @@ export class IntersectionReferenceSystem {
122
132
  project(length: number): number[] {
123
133
  const { curtain } = this.interpolators;
124
134
  const { calculateDisplacementFromBottom } = this.options;
125
- const cl = clamp(calculateDisplacementFromBottom ? this.length - (length - this._offset) : length - this._offset, 0, this.length);
135
+ const cl = clamp(
136
+ calculateDisplacementFromBottom
137
+ ? this.length - (length - this._offset)
138
+ : length - this._offset,
139
+ 0,
140
+ this.length,
141
+ );
126
142
  const p = curtain.getPointAtArcLength(cl, this.options);
127
143
  return p as number[];
128
144
  }
@@ -146,11 +162,19 @@ export class IntersectionReferenceSystem {
146
162
  * @param endMd in MD
147
163
  * @param includeStartEnd guarantee to include the starting and end points
148
164
  */
149
- getCurtainPath(startMd: number, endMd: number, includeStartEnd = false): MDPoint[] {
165
+ getCurtainPath(
166
+ startMd: number,
167
+ endMd: number,
168
+ includeStartEnd = false,
169
+ ): MDPoint[] {
150
170
  if (!this._curtainPathCache) {
151
171
  const points: MDPoint[] = [];
152
172
  let prevAngle = Math.PI * 2; // Always add first point
153
- for (let i = this._offset; i <= this.length + this._offset; i += CURTAIN_SAMPLING_INTERVAL) {
173
+ for (
174
+ let i = this._offset;
175
+ i <= this.length + this._offset;
176
+ i += CURTAIN_SAMPLING_INTERVAL
177
+ ) {
154
178
  const point = this.project(i);
155
179
  const angle = Math.atan2(point[1]!, point[0]!);
156
180
 
@@ -165,11 +189,13 @@ export class IntersectionReferenceSystem {
165
189
 
166
190
  if (includeStartEnd) {
167
191
  const startPoint = { point: this.project(startMd), md: startMd };
168
- const pointsBetween = this._curtainPathCache.filter((p) => p.md > startMd && p.md < endMd);
192
+ const pointsBetween = this._curtainPathCache.filter(
193
+ p => p.md > startMd && p.md < endMd,
194
+ );
169
195
  const endPoint = { point: this.project(endMd), md: endMd };
170
196
  return [startPoint, ...pointsBetween, endPoint];
171
197
  }
172
- return this._curtainPathCache.filter((p) => p.md >= startMd && p.md <= endMd);
198
+ return this._curtainPathCache.filter(p => p.md >= startMd && p.md <= endMd);
173
199
  }
174
200
 
175
201
  /**
@@ -177,7 +203,9 @@ export class IntersectionReferenceSystem {
177
203
  */
178
204
  unproject(displacement: number): number | undefined {
179
205
  const { normalizedLength, calculateDisplacementFromBottom } = this.options;
180
- const displacementFromStart = calculateDisplacementFromBottom ? this.displacement - displacement : displacement;
206
+ const displacementFromStart = calculateDisplacementFromBottom
207
+ ? this.displacement - displacement
208
+ : displacement;
181
209
  const length = normalizedLength || this.length;
182
210
 
183
211
  if (displacementFromStart < 0) {
@@ -187,7 +215,11 @@ export class IntersectionReferenceSystem {
187
215
  return length + (displacementFromStart - this.displacement);
188
216
  }
189
217
 
190
- const ls = this.interpolators.curtain.getIntersectsAsPositions(displacementFromStart, 0, 1);
218
+ const ls = this.interpolators.curtain.getIntersectsAsPositions(
219
+ displacementFromStart,
220
+ 0,
221
+ 1,
222
+ );
191
223
  if (ls && ls.length) {
192
224
  return ls[0]! * length + this._offset;
193
225
  }
@@ -221,8 +253,14 @@ export class IntersectionReferenceSystem {
221
253
  const extensionStart = from < 0 ? -from : 0;
222
254
  const extensionEnd = to > 1 ? to - 1 : 0;
223
255
 
224
- const refStart = this.interpolators.trajectory.getPointAt(0) as [number, number];
225
- const refEnd = this.interpolators.trajectory.getPointAt(1) as [number, number];
256
+ const refStart = this.interpolators.trajectory.getPointAt(0) as [
257
+ number,
258
+ number,
259
+ ];
260
+ const refEnd = this.interpolators.trajectory.getPointAt(1) as [
261
+ number,
262
+ number,
263
+ ];
226
264
 
227
265
  let p0: [number, number];
228
266
  let p3: [number, number];
@@ -243,7 +281,10 @@ export class IntersectionReferenceSystem {
243
281
  }
244
282
 
245
283
  if (extensionEnd) {
246
- p3 = [refEnd[0] + this.endVector[0]! * extensionEnd * this.displacement, refEnd[1] + this.endVector[1]! * extensionEnd * this.displacement];
284
+ p3 = [
285
+ refEnd[0] + this.endVector[0]! * extensionEnd * this.displacement,
286
+ refEnd[1] + this.endVector[1]! * extensionEnd * this.displacement,
287
+ ];
247
288
  }
248
289
  const points = [];
249
290
  const tl = to - from;
@@ -255,15 +296,26 @@ export class IntersectionReferenceSystem {
255
296
  points.push(p0);
256
297
  for (let i = 1; i < preSteps; i++) {
257
298
  const f = (i / preSteps) * extensionStart * this.displacement;
258
- points.push([p0[0] - this.startVector[0]! * f, p0[1] - this.startVector[1]! * f]);
299
+ points.push([
300
+ p0[0] - this.startVector[0]! * f,
301
+ p0[1] - this.startVector[1]! * f,
302
+ ]);
259
303
  }
260
304
  }
261
- const curvePoints = this.interpolators.trajectory.getPoints(curveSteps - 1, null, t0, t1) as number[][]; // returns steps + 1 points
305
+ const curvePoints = this.interpolators.trajectory.getPoints(
306
+ curveSteps - 1,
307
+ null,
308
+ t0,
309
+ t1,
310
+ ) as number[][]; // returns steps + 1 points
262
311
  points.push(...curvePoints);
263
312
  if (p3!) {
264
313
  for (let i = 1; i < postSteps - 1; i++) {
265
314
  const f = (i / postSteps) * extensionEnd * this.displacement;
266
- points.push([p2[0] + this.endVector[0]! * f, p2[1] + this.endVector[1]! * f]);
315
+ points.push([
316
+ p2[0] + this.endVector[0]! * f,
317
+ p2[1] + this.endVector[1]! * f,
318
+ ]);
267
319
  }
268
320
  points.push(p3);
269
321
  }
@@ -279,34 +331,56 @@ export class IntersectionReferenceSystem {
279
331
  endExtensionLength = DEFAULT_END_EXTEND_LENGTH,
280
332
  ): Trajectory {
281
333
  if (!isFinite(startExtensionLength) || startExtensionLength < 0.0) {
282
- throw new Error('Invalid parameter, getExtendedTrajectory() must be called with a valid and positive startExtensionLength parameter');
334
+ throw new Error(
335
+ 'Invalid parameter, getExtendedTrajectory() must be called with a valid and positive startExtensionLength parameter',
336
+ );
283
337
  }
284
338
  if (!isFinite(endExtensionLength) || endExtensionLength < 0.0) {
285
- throw new Error('Invalid parameter, getExtendedTrajectory() must be called with a valid and positive endExtensionLength parameter');
339
+ throw new Error(
340
+ 'Invalid parameter, getExtendedTrajectory() must be called with a valid and positive endExtensionLength parameter',
341
+ );
286
342
  }
287
343
 
288
- const totalLength = this.displacement + startExtensionLength + endExtensionLength;
289
- const startExtensionNumPoints = Math.floor((startExtensionLength / totalLength) * numPoints);
290
- const curveSteps = Math.max(Math.ceil((this.displacement / totalLength) * numPoints), 1);
291
- const endExtensionNumPoints = numPoints - curveSteps - startExtensionNumPoints;
344
+ const totalLength =
345
+ this.displacement + startExtensionLength + endExtensionLength;
346
+ const startExtensionNumPoints = Math.floor(
347
+ (startExtensionLength / totalLength) * numPoints,
348
+ );
349
+ const curveSteps = Math.max(
350
+ Math.ceil((this.displacement / totalLength) * numPoints),
351
+ 1,
352
+ );
353
+ const endExtensionNumPoints =
354
+ numPoints - curveSteps - startExtensionNumPoints;
292
355
 
293
356
  const points = [];
294
357
 
295
- const refStart = new Vector2(this.interpolators.trajectory.getPointAt(0.0) as number[]);
358
+ const refStart = new Vector2(
359
+ this.interpolators.trajectory.getPointAt(0.0) as number[],
360
+ );
296
361
  const startVec = new Vector2(this.startVector);
297
- const startExtensionStepLength = startExtensionLength / startExtensionNumPoints;
362
+ const startExtensionStepLength =
363
+ startExtensionLength / startExtensionNumPoints;
298
364
  for (let i = startExtensionNumPoints; i > 0; i--) {
299
365
  const f = i * startExtensionStepLength;
300
366
  const point = refStart.add(startVec.scale(f));
301
367
  points.push(point.toArray());
302
368
  }
303
369
 
304
- const curveStepPoints = this.interpolators.trajectory.getPoints(curveSteps, null, 0.0, 1.0) as number[][];
370
+ const curveStepPoints = this.interpolators.trajectory.getPoints(
371
+ curveSteps,
372
+ null,
373
+ 0.0,
374
+ 1.0,
375
+ ) as number[][];
305
376
  points.push(...curveStepPoints);
306
377
 
307
- const refEnd = new Vector2(this.interpolators.trajectory.getPointAt(1.0) as number[]);
378
+ const refEnd = new Vector2(
379
+ this.interpolators.trajectory.getPointAt(1.0) as number[],
380
+ );
308
381
  const endVec = new Vector2(this.endVector);
309
- const endExtensionStepLength = endExtensionLength / (endExtensionNumPoints - 1); // -1 so last point is at end of extension
382
+ const endExtensionStepLength =
383
+ endExtensionLength / (endExtensionNumPoints - 1); // -1 so last point is at end of extension
310
384
  for (let i = 1; i < endExtensionNumPoints; i++) {
311
385
  const f = i * endExtensionStepLength;
312
386
  const point = refEnd.add(endVec.scale(f));
@@ -329,7 +403,9 @@ export class IntersectionReferenceSystem {
329
403
 
330
404
  const trajectoryVec = IntersectionReferenceSystem.getDirectionVector(
331
405
  this.interpolators.trajectory,
332
- calculateDisplacementFromBottom ? THRESHOLD_DIRECTION_DISTANCE : 1 - THRESHOLD_DIRECTION_DISTANCE,
406
+ calculateDisplacementFromBottom
407
+ ? THRESHOLD_DIRECTION_DISTANCE
408
+ : 1 - THRESHOLD_DIRECTION_DISTANCE,
333
409
  calculateDisplacementFromBottom ? 0 : 1,
334
410
  );
335
411
  return trajectoryVec;
@@ -361,7 +437,11 @@ export class IntersectionReferenceSystem {
361
437
  * @param from number between 0 and 1
362
438
  * @param to number between 0 and 1
363
439
  */
364
- static getDirectionVector(interpolator: CurveInterpolator, from: number, to: number): number[] {
440
+ static getDirectionVector(
441
+ interpolator: CurveInterpolator,
442
+ from: number,
443
+ to: number,
444
+ ): number[] {
365
445
  const p1 = interpolator.getPointAt(to);
366
446
  const p2 = interpolator.getPointAt(from);
367
447