Task

Draw a   cuboid   with relative dimensions of    2 × 3 × 4. 



The cuboid can be represented graphically, or in   ASCII art,   depending on the language capabilities.

To fulfill the criteria of being a cuboid, three faces must be visible.

Either static or rotational projection is acceptable for this task.



Related tasks
 draw a sphere
 draw a rotating cube
 write language name in 3D ASCII
 draw a Deathstar


include c:\cxpl\codes;                  \intrinsic 'code' declarations
real X, Y, Z, Farthest;                 \arrays: 3D coordinates of vertices
int  I, J, K, SI, Segment;
def  Size=50.0, Sz=0.008, Sx=-0.013;    \drawing size and tumbling speeds
[X:= [-2.0, +2.0, +2.0, -2.0,  -2.0, +2.0, +2.0, -2.0];
 Y:= [-1.5, -1.5, +1.5, +1.5,  -1.5, -1.5, +1.5, +1.5];
 Z:= [-1.0, -1.0, -1.0, -1.0,  +1.0, +1.0, +1.0, +1.0];
Segment:= [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 640x480 graphics with 256 colors
repeat  Farthest:= 0.0;                 \find the farthest vertex
        for I:= 0 to 8-1 do
            if Z(I) > Farthest then [Farthest:= Z(I);  SI:= I];
        Clear;                          \erase screen
        for I:= 0 to 2*12-1 do          \for all the vertices...
            [J:= Segment(I);  I:= I+1;  \get vertex number
            Move(fix(X(J)*Size)+640/2, fix(Y(J)*Size)+480/2);
            K:= Segment(I);
            Line(fix(X(K)*Size)+640/2, fix(Y(K)*Size)+480/2,
                if J=SI ! K=SI then $F009 \dashed blue\ else $C \red\);
            ];
        Sound(0, 1, 1);                 \delay 1/18 second to prevent flicker
        for I:= 0 to 8-1 do
            [X(I):= X(I) + Y(I)*Sz;     \rotate vertices in X-Y plane
             Y(I):= Y(I) - X(I)*Sz;
             Y(I):= Y(I) + Z(I)*Sx;     \rotate vertices in Y-Z plane
             Z(I):= Z(I) - Y(I)*Sx;
            ];
until KeyHit;                           \run until a key is struck
SetVid(3);                              \restore normal text mode (for DOS)
]