CSC-Soft

   
Software development by order
Software development
Order the software
Requirement specification
Developed software
Ready-made solutions
Visual CSC
Visual Logic
MatBasic
Developers group
Contact us
About the company
Forum
 
News
07.11.2008
The first commercial release of the language of mathematical calculations MatBasic v.1.2

06.11.2007
Release of a new version of mathematical programming environment MatBasic v.1.1

26.08.2007
MatBasic mathematical programming environment beta-version release.

09.06.2007
First official build of CSC-Model module of Visual CSC system for calculating steady and emergency regimes.

12.09.2006
The beginning of development of a logic designing system Visual Logic.

04.08.2006
First release of a universal schematic editor Visual CSC.

    MatBasic


  Introduction     Applications     History     Download     Purchase  

    Examples of MatBasic calculation system application

    MatBasic environment can be used for calculations of a wide range of complexity – from school-level sums to sophisticated science problems solution. This part contains several examples of the environment application.

  1. Example: School-level sum "Snowflake"
  2. Program module of checking an algorithmic metering entry to a set polygonal area
  3. Program module of a frequency determination sensor
  4. Simulation model of a synchronous generator

    Task: To make up a program drawing a snowflake. Following values are given by user: number of units, branches, coefficient of every branch unit decrease.

    Algorithm:

  • Verify the necessary parameters, declare them: N – number of units, P – number of branches, L – length of the inner unit branch, K - coefficient of every unit decrease.
  • Place a snowflake center in the origin of coordinates.
  • Start drawing from the center of the snowflake: drawing a first interval (of L length), then if it’s not the last unit draw the next unit interval (of length L/K) and continue till drawing of the last unit interval (L/Kn-1) is finished.
  • Draw the smallest snowflake at the last unit.
  • Return to the next to last interval and draw the smallest snowflake unit.
  • Continue these actions till the whole snowflake is drawn. This drawing logic is easily realized by recursion.

    Listing of a branch drawing recursive function:

% fi - turn angle, depends on P
% Zc – complex point, containing "parrent"-interval end coordinates
% drawn in function branches
function branch(Zc,K,P,N)
  global fi;
  z[1]=Zc[2];
  z[2]=zz=(abs(Zc[2]-Zc[1])/K)*exp(1i*
    (angle(real(Zc[2]-Zc[1]),imag(Zc[2]-Zc[1]))-PI));
  if (N > 1)
    for (n=1:P)
      zz*=fi;
      z[2]=zz+Zc[2];
      plot2d #SNOWFLAKE (real(z),imag(z));
      branch(z,K,P,N-1);
    end
  end
end

    Input data is declared in the very beginning of a program text file:

P=6;
K=4;
N=3;
L=10;
global fi;
fi=exp(1i*2*PI/P);

    The fi variable is declared global as far as it is used both in the function and in the main program body. The program listing is following:

z[1]=0;
z[2]=L*1i;
posplot 1,1;
hldplot on; % Use this for quick output
for (k=1:P)
  plot2d #SNOWFLAKE (real(z),imag(z),axisstyle="boxed",axis="equal");
  branch(z,K,P,N);
  z[2]*=fi;
end

    Setting different values of P, K, N and L variables gives us different snowflake looks at the output (graphical console). For example, values mentioned above will give us a snowflake shown at the left and values P=6, K=3, N=5, L=10 give us a snowflake shown at the right.

A snowflake with a triple nesting of branches (click to view the original size) A snowflake with a fivefold nesting of branches (click to view the original size)

<< To the top








2009 CSC-Soft