Add equal-length constraints & implement UnaryExpressions (#35)
* add segLen help to lang std * adding helpers functions to sketchConstraints * update tokeniser tests because they were annoying me not being 100% * compare async lexer with sync lexer instead * add helper functions * remove unneeded nesting * update add ast modifier function for angledLine * initial equal ast modification It adds a tag to the primary line, and converts any secondary lines to angledLine, but doesn't reference the taged/primary line yet * Update fn call with refernce to previous line using segLen * add test for giveSketchFnCallTag * fix excutor bug, executing call expression in array expression * fix small issue in executor * add CallExpressions to BinaryExpressions * add unary Expressions * tweaks to unaryExpression logic * add recasting for unaryExpressions and CallExpressions in BinaryExpressions * ensure pipe substitution info is passed down to unary expressions and others * allow binary expressions in function argumentns * inital setup, new way of organising sketch fn transforms Starting with equal length * overhaul equalLength button * add equal length support for angledLine * line with one variable supports signed legLength * fix indentation when recasting long arrayExpressions in a pipeExpression * improve modifyAst consision * further modify ast tidy * equalLength transfroms far angledLineOfXLength * add transforms for line-yRelative * add equal constraint for angledLineOfYLength * quick test fix * add equal length constrain transforms for lineTo * add equal length constraints for angledLineToX * add equalLength constraints for angledLineToY * test tidy * setup new vertical-horizontal constraints * Add equal Length constraints for vertical/horizontal lines * migrate old tests, and refactor callback tag * tweaks and refactor horzVert component * fix leg len with small negative leg length
This commit is contained in:
@ -13,6 +13,11 @@ import {
|
||||
closee,
|
||||
startSketchAt,
|
||||
} from './sketch'
|
||||
import {
|
||||
segLen,
|
||||
angleToMatchLengthX,
|
||||
angleToMatchLengthY,
|
||||
} from './sketchConstraints'
|
||||
import { extrude, getExtrudeWallTransform } from './extrude'
|
||||
import { Quaternion, Vector3 } from 'three'
|
||||
import { SketchGroup, ExtrudeGroup, Position, Rotation } from '../executor'
|
||||
@ -70,6 +75,17 @@ const translate: InternalFn = <T extends SketchGroup | ExtrudeGroup>(
|
||||
}
|
||||
}
|
||||
|
||||
const min: InternalFn = (_, a: number, b: number): number => Math.min(a, b)
|
||||
|
||||
const legLen: InternalFn = (_, hypotenuse: number, leg: number): number =>
|
||||
Math.sqrt(hypotenuse ** 2 - Math.min(Math.abs(leg), Math.abs(hypotenuse)) ** 2)
|
||||
|
||||
const legAngX: InternalFn = (_, hypotenuse: number, leg: number): number =>
|
||||
(Math.acos(Math.min(leg, hypotenuse) / hypotenuse) * 180) / Math.PI
|
||||
|
||||
const legAngY: InternalFn = (_, hypotenuse: number, leg: number): number =>
|
||||
(Math.asin(Math.min(leg, hypotenuse) / hypotenuse) * 180) / Math.PI
|
||||
|
||||
export const internalFns: { [key in InternalFnNames]: InternalFn } = {
|
||||
rx: rotateOnAxis([1, 0, 0]),
|
||||
ry: rotateOnAxis([0, 1, 0]),
|
||||
@ -78,6 +94,13 @@ export const internalFns: { [key in InternalFnNames]: InternalFn } = {
|
||||
translate,
|
||||
transform,
|
||||
getExtrudeWallTransform,
|
||||
min,
|
||||
legLen,
|
||||
legAngX,
|
||||
legAngY,
|
||||
segLen,
|
||||
angleToMatchLengthX,
|
||||
angleToMatchLengthY,
|
||||
lineTo: lineTo.fn,
|
||||
xLineTo: xLineTo.fn,
|
||||
yLineTo: yLineTo.fn,
|
||||
|
Reference in New Issue
Block a user