DIRECTORY Real USING [SqRt], Vector2 USING [VEC]; Vector2Impl: CEDAR PROGRAM IMPORTS Real EXPORTS Vector2 ~ BEGIN VEC: TYPE ~ Vector2.VEC; Add: PUBLIC PROC[v1, v2: VEC] RETURNS[VEC] ~ { RETURN[[v1.x+v2.x, v1.y+v2.y]] }; Sub: PUBLIC PROC[v1, v2: VEC] RETURNS[VEC] ~ { RETURN[[v1.x-v2.x, v1.y-v2.y]] }; Neg: PUBLIC PROC[v: VEC] RETURNS[VEC] ~ { RETURN[[-v.x, -v.y]] }; Mul: PUBLIC PROC[v: VEC, s: REAL] RETURNS[VEC] ~ { RETURN[[v.x*s, v.y*s]] }; Div: PUBLIC PROC[v: VEC, s: REAL] RETURNS[VEC] ~ { RETURN[[v.x/s, v.y/s]] }; Square: PUBLIC PROC[v: VEC] RETURNS[REAL] ~ { RETURN[v.x*v.x+v.y*v.y] }; Length: PUBLIC PROC[v: VEC] RETURNS[REAL] ~ { RETURN[Real.SqRt[v.x*v.x+v.y*v.y]] }; Unit: PUBLIC PROC[v: VEC] RETURNS[VEC] ~ { m: REAL ~ Real.SqRt[v.x*v.x+v.y*v.y]; RETURN[[v.x/m, v.y/m]] }; Dot: PUBLIC PROC[v1, v2: VEC] RETURNS[REAL] ~ { RETURN[v1.x*v2.x+v1.y*v2.y] }; Cross: PUBLIC PROC[v1, v2: VEC] RETURNS[REAL] ~ { RETURN[v1.x*v2.y-v1.y*v2.x] }; END. €Vector2Impl.mesa Copyright c 1984, Xerox Corporation. All rights reserved. Doug Wyatt, August 15, 1984 5:12:25 pm PDT Ê+˜šœ™Jšœ Ïmœ/™:Jšœ*™*J™—šÏk ˜ Jšœžœ˜Jšœžœžœ˜J˜—Jšœ žœž˜Jšžœ˜ Jšžœ˜Jšœž˜J˜Jšžœžœ žœ˜J˜šÏnœžœžœ žœžœžœžœ˜PJ˜—šŸœžœžœ žœžœžœžœ˜PJ˜—šŸœžœžœžœžœžœžœ˜AJ˜—šŸœžœžœžœžœžœžœžœ˜LJ˜—šŸœžœžœžœžœžœžœžœ˜LJ˜—šŸœžœžœžœžœžœžœ˜HJ™—šŸœžœžœžœžœžœžœ˜SJ™—š Ÿœžœžœžœžœžœ˜*Jšœžœžœ˜?J˜—šŸœžœžœ žœžœžœžœ˜NJ˜—šŸœžœžœ žœžœžœžœ˜PJ˜—Jšžœ˜—…—Âm