Я использовал очень упрощенный подход:
package tree
// Enum for node category
type Level int32
const (
Leaf Level = iota + 1
Branch
Root
)
type Node struct {
Category Level
Parent *Node
X float32
Y float32
Z float32
Dim float32
RootT float32 // Root thickness
RootD float32 // Root diameter
RootBR float32 // Root bezel ratio of top-bottom, i.e. top D is larger by this much
LeafP float32 // Leaf penetration
}
func NewNode(cat Level, parent *Node, x, y, z, dim float32) *Node {
n := &Node{
Category: cat,
Parent: parent,
X: x,
Y: y,
Z: z,
Dim: dim,
}
switch n.Category {
case Leaf:
n.LeafP = float32(0.3)
case Root:
n.RootT = float32(2)
n.RootD = float32(30)
n.RootBR = float32(1.08)
}
return n
}