Skip to content

Commit

Permalink
better handling of projection when end of path, allow for extension (#…
Browse files Browse the repository at this point in the history
…171)

* better handling of projection when end of path, allow for extension

* clamp values when not using extension

* removed extrapolation option until we have discussed it extensively

Co-authored-by: Brynjulf <[email protected]>
  • Loading branch information
Brynjulf and Brynjulf authored Apr 17, 2020
1 parent 4ed4741 commit f3a50d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .storybook/src/layers/html/highlight.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ export const HighlightWellborepathWithController = () => {
// external event that calls the rescale event the highlighting should change
const slider = createSlider((event: any) => onUpdate(event, { rescaleEvent: controller.currentStateAsEvent, layer: highlightLayer }), {
width,
min: 0,
max: controller.referenceSystem.length,
min: -1000,
max: controller.referenceSystem.length + 1000,
});

root.appendChild(container);
Expand Down
10 changes: 4 additions & 6 deletions src/control/IntersectionReferenceSystem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Vector2 from '@equinor/videx-vector2';
import { clamp } from '@equinor/videx-math';
import { CurveInterpolator, normalize } from 'curve-interpolator';
import { Interpolator, Trajectory, ReferenceSystemOptions } from '../interfaces';

Expand Down Expand Up @@ -71,18 +72,15 @@ export class IntersectionReferenceSystem {
this.endVector = IntersectionReferenceSystem.getDirectionVector(this.interpolators.trajectory, 1 - thresholdDirectionDist, 1);
this.startVector = this.endVector.map((d: number) => d * -1);
}

/**
* Map a length along the curve to intersection coordinates
* @param length length along the curve
*/
project(length: number): number[] {
const { curtain } = this.interpolators;
const l = (length - this._offset) / this.length;
// TODO handle points outside
if (l < 0 || l > 1) {
return [0, 0];
}
const p = curtain.getPointAt(l);
const t = clamp(l, 0, 1);
const p = curtain.getPointAt(t);
return p;
}

Expand Down

0 comments on commit f3a50d4

Please sign in to comment.