algorithmic modeling for Rhino
Hello All,
I am currently working with a few 3d scans of oak tree branches, and I am needing to develop a script which finds the centerline of these branches. (Separating out the primary from secondary branches would be an added bonus.)
I had an idea of using contours to find the center point, then connecting these found center points to create my centerline. However, I am facing a few challenges... specifically, I do not know how deal with splits in the tree branch.
I think I have an idea for how to deal with this, but I am not skilled enough (yet) to execute. The whole idea would look like this:
1) create a list of contours through the tree branch
2) connect the center points of the contour lines
3) when a single contour produces two separate polylines (when the tree splits), AND the previous contour produces only a single polyline, divide the list into two new lists starting at that contour.
4)when a single contour produces two separate polylines, AND the previous contour also produces two separate polylines, draw a polyline between the closest pair of centroids.
Has anyone run into this (or something similar) before? And, is this a good way of going about it?
The attached script is incomplete, but has the oak tree branch internalized.
I have been struggling hard with this....Any help would be greatly appreciated!!
Thanks,
Ethan
Tags:
You could probably make the iterative conditional method work with a bit of scripting. In the end it really depends what format you're looking for the branches to be in. If you're OK with a flat list of branches - you could consider using Prox2D or Prox3D to get individual line segments in between your points. If you tweak the maximum radius you could get a quite reasonable approximation.
It's then possible to use a Prune tree to extract certain points (your branch "end points") that only have 1 line segment extending out from them. Then you can draw lines in between your branch "base" and "tips" (base will probably be furthest out in some direction, so might do a directional sort to isolate - these lines are the ones in light blue below) and feed the network into Shortest Walk.
This should give you polylines from the base of your branch to all the individual tips, which you can then simply trim in order to get your branch lines.
I've attached a short script that does the trick. Note that you'll need to have Shortest walk installed. The parameters work for this branch, but they might need some fiddling for other branches. Let me know if you have any questions!
Dan, this is fantastic!
Still playing around now to see if this is going to work...but I think this is exactly what I was trying to do.
Thank you for your help/guidance!
E
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by