Here's another example of LINE.

I've written a crude D3PLOT demo that uses a D3DRAW to render a matrix of homogenous coordinates

[[ x0 y0 z0 1] [ x1 y1 z1 1] ...] in a viewport configured by D3CFG.

- d3demo_example.jpg (16.26 KiB) Viewed 3142 times

Like, you totally knew this was coming, right?

It's sooo late eighties.

First run D3CFG to set the viewport.

Set the view variables and then PRESS R/S

to initialize the View transformation matrix.

r=distance from origin to viewpoint

theta=angle from X towards Y (degrees)

phi=declination from Z (degrees)

d = screen distance (more of a scaling factor)

r=10

theta=52

phi=72

d=11

Then run D3PLOT and set the X/Y range and steps.

XMIN=-10

XMAX=10

XN=40

YMIN=-10

YMAX=10

YN=40

It is hardcoded with the function NRMRESP.

The code was inspired by the "Perspective" chapter of the out of print "Programming Principles in Computer Graphics", Leendert Ammeraal.

I've got the perspective transformation disabled, because I was having trouble with it.

The quality of the code is "I just wanted to see if I could bang this out."

We need a gallery of beautiful OFFIMG screens that were *generated* by our little DM42s.

Code: Select all

```
00 { 869-Byte Prgm }
01▸LBL "D3CFG"
02 MVAR "r"
03 MVAR "theta"
04 MVAR "phi"
05 MVAR "d"
06 DEG
07 VARMENU "D3CFG"
08 STOP
09 EXITALL
10 4
11 ENTER
12 NEWMAT
13 STO "D3DV"
14 INDEX "D3DV"
15 MVAR "v11"
16 RCL "theta"
17 SIN
18 +/-
19 STOEL
20 J+
21 MVAR "v12"
22 RCL "phi"
23 COS
24 RCL "theta"
25 COS
26 ×
27 +/-
28 STOEL
29 J+
30 MVAR "v13"
31 RCL "phi"
32 SIN
33 RCL "theta"
34 COS
35 ×
36 +/-
37 STOEL
38 J+
39 J+
40 MVAR "v21"
41 RCL "theta"
42 COS
43 STOEL
44 J+
45 MVAR "v22"
46 RCL "phi"
47 COS
48 RCL "theta"
49 SIN
50 ×
51 +/-
52 STOEL
53 J+
54 MVAR "v23"
55 RCL "phi"
56 SIN
57 RCL "theta"
58 SIN
59 ×
60 +/-
61 STOEL
62 J+
63 J+
64 J+
65 MVAR "v32"
66 RCL "phi"
67 SIN
68 STOEL
69 J+
70 MVAR "v33"
71 RCL "phi"
72 COS
73 +/-
74 STOEL
75 I+
76 MVAR "v43"
77 RCL "r"
78 STOEL
79 J+
80 MVAR "v44"
81 1
82 STOEL
83 RTN
84▸LBL "D3DRAW"
85 RCL× "D3DV"
86 STO "D3DE"
87 INDEX "D3DE"
88 GTO 03
89 MVAR "etop"
90▸LBL 01
91 J+
92 J+
93 RCLEL
94 J-
95 RCLEL
96 RCL÷ ST Y
97 STOEL
98 J-
99 RCLEL
100 RCL÷ ST Z
101 STOEL
102 I+
103 FC? 76
104 GTO 01
105▸LBL 03
106 MVAR "deletez"
107 RCL "D3DE"
108 DIM?
109 RCL ST Y
110 X<>Y
111 CLX
112 1
113 GETM
114 RCL× "d"
115 RCL "ResX"
116 2
117 ÷
118 +
119 J+
120 RCL ST Y
121 1
122 GETM
123 RCL× "d"
124 +/-
125 RCL "ResY"
126 2
127 ÷
128 +
129 COMPLEX
130 XEQ "PATH"
131 RTN
132 MVAR "v180212"
133 END
134▸LBL "NRMRESP"
135 RCL "X"
136 RCL "Y"
137▸LBL "NRMR2"
138 RAD
139 X↑2
140 X<>Y
141 X↑2
142 +
143 SQRT
144 SIN
145 LASTX
146 X=0?
147 GTO 00
148 ÷
149 10
150 ×
151 RTN
152▸LBL 00
153 10
154 RTN
155 MVAR "v180212"
156 END
157▸LBL "D3PLOT"
158 MVAR "XMIN"
159 MVAR "XMAX"
160 MVAR "XN"
161 MVAR "YMIN"
162 MVAR "YMAX"
163 MVAR "YN"
164 VARMENU "D3PLOT"
165 STOP
166 EXITALL
167 MVAR "deltaxy"
168 RCL "XMAX"
169 RCL- "XMIN"
170 RCL÷ "XN"
171 STO 01
172 RCL "YMAX"
173 RCL- "YMIN"
174 RCL÷ "YN"
175 STO 02
176 MVAR "fory"
177 RCL "YMIN"
178 STO "Y"
179 RCL "YN"
180 1
181 +
182 STO 06
183 4
184 NEWMAT
185 STO "D3DYPTH"
186 MVAR "forx"
187▸LBL 01
188 INDEX "D3DYPTH"
189 RCL "XN"
190 1
191 +
192 STO 05
193 RCL "XMIN"
194 STO "X"
195▸LBL 02
196 RCL "X"
197 STOEL
198 J+
199 RCL "Y"
200 STOEL
201 J+
202 XEQ "NRMRESP"
203 STOEL
204 J+
205 1
206 STOEL
207 J+
208 MVAR "nextx"
209 RCL 01
210 STO+ "X"
211 DSE 05
212 GTO 02
213 RCL "D3DYPTH"
214 XEQ "D3DRAW"
215 MVAR "nexty"
216 RCL 02
217 STO+ "Y"
218 DSE 06
219 GTO 01
220 MVAR "initx2"
221 RCL "XMIN"
222 STO "X"
223 RCL "XN"
224 1
225 +
226 STO 05
227 4
228 NEWMAT
229 STO "D3DXPTH"
230 MVAR "forx2"
231▸LBL 03
232 INDEX "D3DXPTH"
233 RCL "YN"
234 1
235 +
236 STO 06
237 RCL "YMIN"
238 STO "Y"
239▸LBL 04
240 RCL "X"
241 STOEL
242 J+
243 RCL "Y"
244 STOEL
245 J+
246 XEQ "NRMRESP"
247 STOEL
248 J+
249 1
250 STOEL
251 J+
252 MVAR "nexty2"
253 RCL 02
254 STO+ "Y"
255 DSE 06
256 GTO 04
257 RCL "D3DXPTH"
258 XEQ "D3DRAW"
259 MVAR "nextx2"
260 RCL 01
261 STO+ "X"
262 DSE 05
263 GTO 03
264 RTN
265 MVAR "v180212"
266 END
```

-tim