Change perpendicular-distance constraint to something more intuitive to setting parallel distance (#110)

* some clean up

* Change perpendicular-distance constraint to something more intuitive to setting parallel distance

* delete

* add back

* force rename

* change name back

* try renaming again
This commit is contained in:
Kurt Hutten
2023-04-08 14:16:49 +10:00
committed by GitHub
parent 0fa56c3f15
commit 2fc68e7c82
10 changed files with 146 additions and 23 deletions

View File

@ -11,7 +11,10 @@ import { InternalFn } from './stdTypes'
export function getSketchSegmentFromSourceRange(
sketchGroup: SketchGroup,
[rangeStart, rangeEnd]: SourceRange
): SketchGroup['value'][number] {
): {
segment: SketchGroup['value'][number]
index: number
} {
const startSourceRange = sketchGroup.start?.__geoMeta.sourceRange
if (
startSourceRange &&
@ -19,14 +22,18 @@ export function getSketchSegmentFromSourceRange(
startSourceRange[1] >= rangeEnd &&
sketchGroup.start
)
return sketchGroup.start
return { segment: sketchGroup.start, index: -1 }
const line = sketchGroup.value.find(
const lineIndex = sketchGroup.value.findIndex(
({ __geoMeta: { sourceRange } }) =>
sourceRange[0] <= rangeStart && sourceRange[1] >= rangeEnd
)
const line = sketchGroup.value[lineIndex]
if (!line) throw new Error('could not find matching line')
return line
return {
segment: line,
index: lineIndex,
}
}
export const segLen: InternalFn = (