From 5433719440d8d9392c62a55162e871026fb90ec4 Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Mon, 9 Oct 2023 23:23:10 -0700 Subject: [PATCH] feat: Implement 'similar' point method for Steve Gray problem --- src/adapptlet.civet | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/adapptlet.civet b/src/adapptlet.civet index 010e0fd..e049d75 100644 --- a/src/adapptlet.civet +++ b/src/adapptlet.civet @@ -500,9 +500,26 @@ classHandler: Record := [center, direction] := args.subpoints // Note clockwise 90° rotation (3π/2) confirmed in Joyce source commands.push `${name} = Rotate(${direction}, 3*pi/2, ${center})` - 'proportion' - pt := args.subpoints + /proportion|similar/ + pt .= args.subpoints unless pt then return + // reduce the similar case to general proportion + if method is 'similar' + unless pt.length is 5 then return + sourcePlane .= '' + destPlane .= '' + if is3d + unless args.plane then return + destPlane = `, ${args.plane[0]}` + if args.plane.length > 1 + sourcePlane = `, ${args.plane[1]}` + else + sourcePlane = `, Plane(${pt[2]}, ${pt[3]}, ${pt[4]})` + angle := `Angle(${pt[3]}, ${pt[2]}, ${pt[4]}${sourcePlane})` + commands.push + `${aux} = Rotate(${pt[1]}, ${angle}, ${pt[0]}${destPlane})` + auxiliaries.push aux + pt = [pt[2], pt[3], pt[2], pt[4], pt[0], pt[1], pt[0], aux] len := `Distance(${pt[2]},${pt[3]})*Distance(${pt[4]},${pt[5]})` + `/ Distance(${pt[0]},${pt[1]})` direction := `UnitVector(Vector(${pt[6]}, ${pt[7]}))`