DIRECTORY ControllerDefs: FROM "ControllerDefs", PointDefs: FROM "PointDefs", XFormDefs: FROM "XFormDefs", Real: FROM "Real", GriffinMemoryDefs USING [CZone]; PointFns: CEDAR PROGRAM IMPORTS Real,XFormDefs,ControllerDefs, GriffinMemoryDefs EXPORTS PointDefs= BEGIN OPEN PointDefs, GriffinMemoryDefs; xyzw: INTEGER; ScrToObjMatrix: XFormDefs.XFMDescriptor _ CZone.NEW[XFormDefs.XFormMatrix]; ObjToScrMatrix: XFormDefs.XFMDescriptor _ CZone.NEW[XFormDefs.XFormMatrix]; ValScale: REAL; OutOfRange: PUBLIC SIGNAL[value: REAL] = CODE; ObjValToScrVal: PUBLIC PROCEDURE [val: REAL] RETURNS [INTEGER] = BEGIN int: INTEGER; val _ val*ValScale; int _ Real.RoundI[val]; RETURN[int]; END; ObjToScr: PUBLIC PROCEDURE [pt: ObjPt] RETURNS [ScrPt] = BEGIN scr: ScrPt; pt _ XFormDefs.XFormPt[pt,ObjToScrMatrix]; scr[X] _ Real.RoundI[pt[X]]; scr[Y] _ Real.RoundI[pt[Y]]; RETURN[scr]; END; ScrValToObjVal: PUBLIC PROCEDURE [val: INTEGER] RETURNS [REAL] = BEGIN real: REAL _ val/ValScale; RETURN[real]; END; ScrToObj: PUBLIC PROCEDURE [pt: ScrPt] RETURNS [ObjPt] = BEGIN obj: ObjPt; FOR xyzw IN [X..Y] DO obj[xyzw] _ pt[xyzw]; --convert to REAL ENDLOOP; obj _ XFormDefs.XFormPt[obj,ScrToObjMatrix]; RETURN[obj]; END; ObjToScrReal: PUBLIC PROCEDURE [pt: ObjPt] RETURNS [ScrRealPt] = { srp: ScrRealPt _ XFormDefs.XFormPt[pt,ObjToScrMatrix]; RETURN[srp]; }; ScrRealToObj: PUBLIC PROCEDURE [pt: ScrRealPt] RETURNS [ObjPt] = { obj: ObjPt _ XFormDefs.XFormPt[pt,ScrToObjMatrix]; RETURN[obj]; }; ScrToScrReal: PUBLIC PROCEDURE [pt: ScrPt] RETURNS [ScrRealPt] = { RETURN[[pt[X], pt[Y]]]; }; ScrRealToScr: PUBLIC PROCEDURE [pt: ScrRealPt] RETURNS [ScrPt]= { RETURN[[Real.RoundI[pt[X]], Real.RoundI[pt[Y]]]]; }; InitPointFns: PUBLIC PROCEDURE = BEGIN OPEN XFormDefs; DController: ControllerDefs.DisplayController _ ControllerDefs.ReadDisplayController[]; HController: ControllerDefs.HardcopyController _ ControllerDefs.ReadHardcopyController[]; realpt,dcenterobj: ObjPt; hcenterscr: ScrPt; BEGIN OPEN DController,HController; --only for open InitXForms[ObjToScrMatrix]; Scale[[dxscale,dyscale],ObjToScrMatrix]; ValScale _ dxscale; --arbitrary choice InitXForms[ScrToObjMatrix]; Scale[[1/dxscale,1/dyscale],ScrToObjMatrix]; dcenterobj _ XFormPt[[dxcenter,dycenter],ScrToObjMatrix]; realpt _ [hxcenter,hycenter]; hcenterscr _ ObjToScr[realpt]; Translate[[dcenterobj[X]-hxcenter,dcenterobj[Y]-hycenter],ObjToScrMatrix]; Translate [[hcenterscr[X]-INTEGER[dxcenter],hcenterscr[Y]-INTEGER[dycenter]],ScrToObjMatrix]; END; END; END .. m.stone September 26, 1980 5:12 PM PointDefs Last Edited by: Stone, January 26, 1983 4:22 pm real space to screen space. Float will return an error if pt is out of range of 32 bits This will signal if pt is not in [32767..-32768]. ie, inside 16 bits, 2's compliment Ê<˜J˜Jšœ#™#Jšœ ™ Jšœ/™/šÏk ˜ Jšœœ˜&Jšœ œ ˜Jšœ œ ˜Jšœœ˜Jšœœ ˜ —J˜Jšœ ˜Jšœ1˜8Jšœ ˜Jšœœ˜(Jšœœ˜Jšœ0œ˜KJšœ0œ˜KJšœ œ˜J˜Jš œ œœœœ˜.J˜JšœX™XJšœU™UJš Ïnœœ œœœœ˜@Jš˜Jšœœ˜ J˜J˜Jšœ˜ Jšœ˜J˜Jšžœœ œ œ ˜8Jš˜J˜ J˜*J˜J˜Jšœ˜ Jšœ˜J˜Jš žœœ œœœœ˜@Jš˜Jšœœ˜Jšœ˜ Jšœ˜J˜Jšžœœ œ œ ˜8Jš˜J˜ šœœ˜JšœÏc˜'Jšœ˜—J˜,Jšœ˜ Jšœ˜J˜šž œœ œ˜BJšœ6˜6Jšœ˜ J˜J˜—šž œœœ ˜BJ˜2Jšœ˜ J˜J˜—šž œœ œ˜BJšœ˜J˜—šž œœœ ˜AJšœ+˜1J˜—Jšž œœ œ˜ Jšœœ ˜J˜WJ˜YJ˜J˜J˜šœœŸ˜3J˜J˜(—˜JšœŸ˜&—˜J˜J˜,—˜J˜9J˜J˜J˜J˜ Jšœœœ˜S—Jšœ˜—Jšœ˜J˜Jšœ˜—…— Ö&