#!/bin/sh

# Usage: tree maxDepth angle distance
# Internally: (Usage: tree currentDepth maxDepth angle distance)

# Not enough args
if [ -z $3 ]
then
echo Usage: $0 maxDepth angle distance
echo for example
echo "honeycomb:     $0 8 60 20"
echo "tree:          $0 6 25 10"
echo "spider in web: $0 8 112 30"
echo 
exit 0
fi

# if called by a user, start at depth 0
if [ $# = "3" ]
then
$0 0 $1 $2 $3
exit 0
fi

count=`expr $1 + 1`

if [ $count != $2  ] 
then

# --- Draw left branches ---
echo HT
echo LT $3
echo FD $4
$0 $count $2 $3 $4

# -- Go back a step and draw right ones ---
echo KT
echo RT $3
echo FD $4
$0 $count $2 $3 $4

else
exit 0
fi
