CONST WidthFactor = 2000; PROC DrawCube2D(dist, p000, p100, p010, p001, p110, p011, p101, p111) IS SAVE PS IN PS.SetEndStyle(PS.RoundEnds); PS.SetJointStyle(PS.RoundJoints); PS.SetWidth(WidthFactor / dist); PS.MoveTo(p001); PS.LineTo(p101); PS.LineTo(p111); PS.LineTo(p011); PS.Close(); Line.Draw(p100, p101); Line.Draw(p010, p011); Line.Draw(p110, p111); Line.Draw(p110, p100); Line.Draw(p110, p010); PS.Stroke(); SAVE PS IN PS.SetColor(Color.Red); Arrow.Straight(p000, p100) END; SAVE PS IN PS.SetColor(Color.Green); Arrow.Straight(p000, p010) END; SAVE PS IN PS.SetColor(Color.Blue); Arrow.Straight(p000, p001) END END END; PROC DrawCube(org, dist, dir) IS IF VAR D = 100, P000 = [0, 0, 0], p000 ~ (200, 200), P100 ~ [200, 0, 0], p100 ~ (187.3, 185.3), P010 ~ [0, 200, 0], p010 ~ (221, 193.9), P001 ~ [0, 0, 200], p001 ~ (200, 221.2), P110 ~ [200, 200, 0], p110 ~ 0, P011 ~ [0, 200, 200], p011 ~ 0, P101 ~ [200, 0, 200], p101 ~ 0, P111 ~ [200, 200, 200], p111 ~ 0 IN P100 = [D, 0, 0] AND P010 = [0, D, 0] AND P001 = [0, 0, D] AND P110 = [D, D, 0] AND P011 = [0, D, D] AND P101 = [D, 0, D] AND P111 = [D, D, D] AND p000 = Proj3D.Project(P000, org, dist, dir) AND p100 = Proj3D.Project(P100, org, dist, dir) AND p010 = Proj3D.Project(P010, org, dist, dir) AND p001 = Proj3D.Project(P001, org, dist, dir) AND p110 = Proj3D.Project(P110, org, dist, dir) AND p011 = Proj3D.Project(P011, org, dist, dir) AND p101 = Proj3D.Project(P101, org, dist, dir) AND p111 = Proj3D.Project(P111, org, dist, dir) -> DrawCube2D(dist, p000, p100, p010, p001, p110, p011, p101, p111) END FI END; CONST MinDist = 200, MaxDist = 1000, ToDegrees = 180 / Math.Pi; FUNC x = MapDist(t) IS x = MinDist + t * (MaxDist - MinDist) END; FUNC theta = MapDir(t) IS theta = (t - 0.5) * 2 * Math.Pi END; FUNC theta = MapElev(t) IS theta = (t - 0.5) * Math.Pi END; FUNC res = DirVector(t1, t2) IS (E k = COS(t2) :: res = [k * COS(t1), k * SIN(t1), SIN(t2)]) END; (* Return a vector in R3 for the direction corresponding to a direction in the XY plane of t1 radians (t1 = 0 corresponds to a direction along the X axis) and an elevation above the XY plane of t2 radians. *) PROC Cmd0() IS IF VAR a = (47.72, 654.6), b = (388.5, 656.1), c ~ (206.8, 621.2), dist ~ 573, theta1 ~ 0.4597, theta2 ~ 0.2849, dir ~ [0.8601, 0.4258, 0.2809], d = (43.93, 590.9), e = (387.8, 585.6), f ~ (240.8, 576.5), g = (43.93, 512), h = (386.3, 501.4), i ~ (246.1, 505.2), origin = (193.9, 176.7) IN dist = MapDist(Rel.InvX(c, a, b)) AND theta1 = MapDir(Rel.InvX(f, d, e)) AND theta2 = MapElev(Rel.InvX(i, g, h)) AND dir = DirVector(theta1, theta2) -> Type.C(c, Unparse.Value(dist)); Type.C(f, Unparse.Value(theta1 * ToDegrees)); Type.C(i, Unparse.Value(theta2 * ToDegrees)); DrawCube(origin, dist, dir) END FI END;