Skip to content

matrix_3D.gle

This library is designed to plot 3D BAR graphs of square matrices


Global constants with typical values:


mmax (4 or 16) size of the matrix

r (6 cm) the matrix is drawn to a 3D cube r.r.r

alfa (25 deg) rotation of the cube in horizontal direction

beta (30 deg) rotation of the cube in vertical direction


x0,y0 position of the left bottom corner of the cube

xgrp, ygrp position of the perspective point of infinity

persp_scale (3) perspective scale


z_axis_min z_axis_bottom_value

z_axis_max z_axis_top_value

z0 baseline for drawing 3D bars up or down


Used colors:


color_frame\(, col_T\), col_L\(, col_R\), col_BR\(, col_BL\)


Important subroutines

sub project_3D2D s1 s2 s3

Takes one point of 3D box [s1,s2,s3] and calculates its position in

the picture [xgr,ygr]

sub draw_back_frame

Draws three back lines of the cube.

sub draw_middle_frame

Draws six additional lines of the cube.

sub draw_front_frame

Draws three front lines of the cube.

sub normalize_z zvalue

Calculates normalized z coordinate in a range (0,1)

(zvalue - bottom_z_value)/(top_z_value - bottom_z_value)

sub draw_bar_z i j zvalue

Draws one bar, (i,j) element of the matrix with a given value (zvalue).

sub draw_matrix_row k l

Draws one row of the matrix. The subroutine reads one row of the matrix

and displays the elements in reverse order (the last one the first).

This condition ensures correct resulting visualization.

sub draw_z_ticks h1 h2 h3

Draws ticks with labels to z_axis: from h1, to h2, with a step h3.

The format of z_axis labels can be set, e.g.

formatz$ = "fix 2"

sub draw_xy_ticks

Draws ticks to x_axis and y_axis

sub label_x i txt$

Draws label txt$ to i-th x_axis tick.

sub label_y i txt$

Draws label txt$ to i-th y_axis tick.


sub project_3D2D s1 s2 s3

sub od_do a1 a2 a3 b1 b2 b3

sub _do b1 b2 b3

sub draw_back_frame

sub draw_middle_frame

sub draw_front_frame

sub draw_bar_z_zero i j

sub draw_bar_z_up i j z

sub draw_bar_z_down i j z

sub normalize_z zvalue       !zvalue  (0 , 1)

sub normalize_z0 zvalue       !zvalue  (0 , 1)

sub draw_bar_z i j zvalue

sub draw_matrix_row k l

sub draw_z_ticks h1 h2 h3

sub draw_xy_ticks

sub draw_xy_ticks2 po

sub label_x i txt$

sub label_y i txt$

sub draw_bar_graph_3d f$