Community Home Xpress Home
FICO
Xpress banner
FICO Xpress Examples Repository
Back to examples browserNext example

Displays a fractal tree by drawing two branches recursively

Description

Uses functions from the mmive library to draw into the "User graph" pane of the Run bar.


Source Files





fractal_tree.mos

(!******************************************************
   Xpress-IVE Example
   ================== 

   file fractal_tree.mos
   `````````````````````
   Displays a fractal tree by drawing two branches
   recursively
   
   Uses functions from the mmive library to draw into
   the "User graph" pane of the Run bar.
   
   (c) 2008 Fair Isaac Corporation
       Creation: 2002, rev. Apr. 2014
*******************************************************!)

model fractal_tree
uses "mmive"

declarations
  N=9
  RN=1..N
  level: array(RN) of integer
end-declarations

forall (i in RN) do
  level(i):=
  IVEaddplot("level "+(N+1-i),IVE_GREEN div 2+70000*(i div 2)+30000*(i div 3))
end-do

procedure branch(x:real,y:real,d:real,t:real, depth:integer)
  if depth>=0 then
    IVEdrawline(level(depth+1),x,y,x+cos(t),y+sin(t))
       branch(x+cos(t),y+sin(t),d-d/10+d/5*random,t-0.55+1.2*random,depth-1)
       branch(x+cos(t),y+sin(t),d-d/10+d/5*random,t-0.55+1.2*random,depth-1)
  end-if
end-procedure

branch(0,0,40,1.57,N-1)

end-model

Back to examples browserNext example