Tree

Trees

class vSCAD.Tree.tree.BinaryTree(start_point, length, angle, depth, diameter=2, num_points_base=100)[source]

Bases: object

calculate_diameter(diameter)[source]

Calculates the diameter of the branch based on Murray’s law.

Parameters:

diameter (float) – The diameter of the parent branch.

Returns:

The calculated diameter for the child branch.

Return type:

float

draw_tree()[source]

Begins recursive tree generation.

Returns:

A list of Branch objects representing the generated tree.

Return type:

list of Branch

generate_tree(start_point, length, diameter, num_points, angle, depth)[source]

Generates a binary tree structure recursively.

Parameters:
  • start_point (np.ndarray) – The starting point of the current branch as a 3D coordinate.

  • length (float) – The length of the current branch.

  • diameter (float) – The diameter of the current branch.

  • num_points (int) – The number of points to generate along the branch.

  • angle (float) – The angle (in radians) of the current branch relative to the parent.

  • depth (int) – The remaining depth of recursion (number of branching levels).

Returns:

A list of Branch objects representing the generated tree structure.

Return type:

list of Branch

set_branch_length_reduction(reduction)[source]

Sets the branch length reduction factor for the tree generation.

Parameters:

reduction (float) – The reduction factor for branch length.

set_murray_exponent(exponent)[source]

Sets the Murray’s law exponent for the tree generation.

Parameters:

exponent (float) – The exponent value to use in Murray’s law.

class vSCAD.Tree.tree.Branch(start_point, end_point, start_diameter, end_diameter, num_points)[source]

Bases: object

class vSCAD.Tree.tree.NodalTree(connectivity, points, diameters, num_points)[source]

Bases: object

draw_tree()[source]

Generates branch objects for each branch (row) in the connectivity matrix.

Returns:

A list of Branch objects.

Return type:

list of Branch