functional sketch working (#26)
* functional sketch working With old sketch block still there * get all version of lines working with add line and update line * remove old ui state types * some clean up * rename some things * add todo for multi cursor * shorten useStore repitition * small type improvement * big overhaul to group sketch function and they ast modifying helpers together * unneeded tweak * ruthlessly rip out sketch logic * clean up path keyword * getting sketch on face working again with all the new sketch line types * add a bunch of tests and re-arrage file structure
This commit is contained in:
@ -1,7 +1,24 @@
|
||||
import { Range } from '../useStore'
|
||||
|
||||
export const isOverlapping = (a: Range, b: Range) => {
|
||||
const startingRange = a[0] < b[0] ? a : b
|
||||
const secondRange = a[0] < b[0] ? b : a
|
||||
return startingRange[1] >= secondRange[0]
|
||||
export function isOverlap(a: Range, b: Range) {
|
||||
const [startingRange, secondRange] = a[0] < b[0] ? [a, b] : [b, a]
|
||||
const [lastOfFirst, firstOfSecond] = [startingRange[1], secondRange[0]]
|
||||
return lastOfFirst >= firstOfSecond
|
||||
}
|
||||
|
||||
export function roundOff(num: number, places: number = 2): number {
|
||||
const x = Math.pow(10, places)
|
||||
return Math.round(num * x) / x
|
||||
}
|
||||
|
||||
export function getLength(a: [number, number], b: [number, number]): number {
|
||||
const x = b[0] - a[0]
|
||||
const y = b[1] - a[1]
|
||||
return Math.sqrt(x * x + y * y)
|
||||
}
|
||||
|
||||
export function getAngle(a: [number, number], b: [number, number]): number {
|
||||
const x = b[0] - a[0]
|
||||
const y = b[1] - a[1]
|
||||
return ((Math.atan2(y, x) * 180) / Math.PI + 360) % 360
|
||||
}
|
||||
|
Reference in New Issue
Block a user