29 lines
1.5 KiB
Text
29 lines
1.5 KiB
Text
def Size=100., Speed=0.05; \drawing size and rotation speed
|
|
real X, Y, Z, Farthest; \arrays: 3D coordinates of vertices
|
|
int I, J, K, ZI, Edge;
|
|
def R2=sqrt(2.), R3=sqrt(3.), R13=sqrt(1./3.), R23=sqrt(2./3.), R232=R23*2.;
|
|
\vertex:0 1 2 3 4 5 6 7
|
|
[X:= [ 0., R2, 0., -R2, 0., R2, 0., -R2];
|
|
Y:= [ -R3, -R13, R13, -R13, -R13, R13, R3, R13];
|
|
Z:= [ 0., -R23, -R232, -R23, R232, R23, 0., R23];
|
|
Edge:= [0,1, 1,2, 2,3, 3,0, 4,5, 5,6, 6,7, 7,4, 0,4, 1,5, 2,6, 3,7];
|
|
SetVid($101); \set 640x480x8 graphics
|
|
repeat Farthest:= 0.0; \find the farthest vertex
|
|
for I:= 0 to 8-1 do
|
|
if Z(I) > Farthest then [Farthest:= Z(I); ZI:= I];
|
|
Clear; \erase screen
|
|
for I:= 0 to 2*12-1 do \for all the vertices...
|
|
[J:= Edge(I); I:= I+1; \get vertex numbers for edge
|
|
Move(Fix(X(J)*Size)+640/2, Fix(Y(J)*Size)+480/2);
|
|
K:= Edge(I);
|
|
Line(Fix(X(K)*Size)+640/2, Fix(Y(K)*Size)+480/2,
|
|
if J=ZI ! K=ZI then $F001 \dashed blue\ else $0C \red\);
|
|
];
|
|
DelayUS(55000);
|
|
for I:= 0 to 8-1 do
|
|
[X(I):= X(I) + Z(I)*Speed; \rotate vertices about Y axis
|
|
Z(I):= Z(I) - X(I)*Speed; \ (which rotates in X-Z plane)
|
|
];
|
|
until KeyHit; \run until a key is struck
|
|
SetVid(3); \restore normal text mode
|
|
]
|