feat: Implement 'similar' point method for Steve Gray problem

This commit is contained in:
Glen Whitney 2023-10-09 23:23:10 -07:00
parent a236e15990
commit 5433719440

View File

@ -500,9 +500,26 @@ classHandler: Record<JoyceClass, ClassHandler> :=
[center, direction] := args.subpoints [center, direction] := args.subpoints
// Note clockwise 90° rotation (3π/2) confirmed in Joyce source // Note clockwise 90° rotation (3π/2) confirmed in Joyce source
commands.push `${name} = Rotate(${direction}, 3*pi/2, ${center})` commands.push `${name} = Rotate(${direction}, 3*pi/2, ${center})`
'proportion' /proportion|similar/
pt := args.subpoints pt .= args.subpoints
unless pt then return 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]})` len := `Distance(${pt[2]},${pt[3]})*Distance(${pt[4]},${pt[5]})`
+ `/ Distance(${pt[0]},${pt[1]})` + `/ Distance(${pt[0]},${pt[1]})`
direction := `UnitVector(Vector(${pt[6]}, ${pt[7]}))` direction := `UnitVector(Vector(${pt[6]}, ${pt[7]}))`