feat: Get all of Rostamian's old pages working #44

Merged
glen merged 4 commits from rostamian_old into main 2023-10-18 01:07:58 +00:00
Showing only changes of commit 71a3fd4cc4 - Show all commits

View File

@ -257,6 +257,7 @@ function jToG(
cmdr.callbacks.push (api: AppletObject) => cmdr.callbacks.push (api: AppletObject) =>
for each aux of cmdr.auxiliaries for each aux of cmdr.auxiliaries
api.setAuxiliary aux, true api.setAuxiliary aux, true
api.setLabelVisible aux, false
api.setVisible aux,false api.setVisible aux,false
// set up the pivot if there is one // set up the pivot if there is one
@ -405,7 +406,6 @@ function pivotListener(slider: string)
for each anchor of pd.rotatable for each anchor of pd.rotatable
relX[anchor] = pd.api.getXcoord(anchor) - pX relX[anchor] = pd.api.getXcoord(anchor) - pX
relY[anchor] = pd.api.getYcoord(anchor) - pY relY[anchor] = pd.api.getYcoord(anchor) - pY
console.log 'Unfixing', anchor, relX[anchor], relY[anchor]
pd.api.setFixed anchor, false pd.api.setFixed anchor, false
ct := Math.cos rotation ct := Math.cos rotation
st := Math.sin rotation st := Math.sin rotation
@ -414,7 +414,6 @@ function pivotListener(slider: string)
rY := relY[anchor]*ct + relX[anchor]*st rY := relY[anchor]*ct + relX[anchor]*st
pd.api.setCoords(anchor, rX + pX, rY + pY) pd.api.setCoords(anchor, rX + pX, rY + pY)
if pd.fixed[anchor] if pd.fixed[anchor]
console.log 'Re-fixing', anchor, rX, rY
pd.api.setFixed anchor, true pd.api.setFixed anchor, true
function invisible(cname: string): boolean function invisible(cname: string): boolean
@ -712,6 +711,41 @@ classHandler: Record<JoyceClass, ClassHandler> :=
madeSegment = true madeSegment = true
else else
commands.push `${aux}2 = Translate(${oldEnd}, ${aux}1)` commands.push `${aux}2 = Translate(${oldEnd}, ${aux}1)`
'perpendicular'
pt := args.subpoints
unless pt then return
inPlane .= ''
if cdata.is3d
unless args.plane?.length is 1 then return
inPlane = `,${args.plane[0]}`
switch pt.length
when 2
ends[0] = pt[0]
ends[1] = aux
auxiliaries.push aux
if args.line?.length is 1
ln := args.line[0]
commands.push
`${name} = Rotate(${ln}, 3*pi/2, ${pt[0]}${inPlane})`
`${aux} = Vertex(${name}, 2)`
madeSegment = true
else
commands.push
`${aux} = Rotate(${pt[1]}, 3*pi/2, ${pt[0]}${inPlane})`
when 3
return // TODO: line perpendicular to plane
when 4
ends[0] = pt[0]
ends[1] = aux + 2
auxiliaries.push aux+1, aux+2
commands.push
`${aux}1 = Rotate(${pt[1]}, 3*pi/2, ${pt[0]}${inPlane})`
unitVec := `UnitVector(Vector(${pt[0]}, ${aux}1))`
dist := `Distance(${pt[2]}, ${pt[3]})`
commands.push
`${aux}2 = Translate(${pt[0]}, ${dist}*${unitVec})`
else return
unless madeSegment unless madeSegment
commands.push `${name} = Segment(${ends[0]},${ends[1]})` commands.push `${name} = Segment(${ends[0]},${ends[1]})`
callbacks.push (api: AppletObject) => api.setLabelVisible name, true callbacks.push (api: AppletObject) => api.setLabelVisible name, true