! 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. r = 6 color_frame$ = "black" col_T$ = "rgb(1,.8,.8)" col_L$ = "rgb(.8,.8,1)" col_R$ = "rgb(.8,1,.8)" col_BR$ = "rgb(.6,.6,1)" col_BL$ = "rgb(.6,1,.6)" dmin = z_axis_min dmax = z_axis_max sa = sin(torad(alfa)) ca = cos(torad(alfa)) sb = sin(torad(beta)) cb = cos(torad(beta)) ux = todeg(atan((ca/sa)*sb)) uy = -todeg(atan((sa/ca)*sb)) x0 = 0; y0 = 0 set join round just cc !----------------------------------------------------------- sub project_3D2D s1 s2 s3 xgr = x0+r*(s1*ca+s2*sa) local zp = s1*sa-s2*ca ygr = y0+r*(s3*cb-zp*sb) zp = s3*sb+zp*cb ! perspektiva if (zpdmax) then dmax=zvalue end if vys=(zvalue-z_axis_min)/(z_axis_max-z_axis_min) return vys end sub !----------------------------------------------------------- sub normalize_z0 zvalue !zvalue (0 , 1) local vys vys=(zvalue-z_axis_min)/(z_axis_max-z_axis_min) return vys end sub !----------------------------------------------------------- sub draw_bar_z i j zvalue z=normalize_z(zvalue) if (z>z0) then draw_bar_z_up i j z else if (z