This question is closed. Reopen it to edit or answer.

Another take on cyl <-> cyl interaction, asking for speed tips

1 view (last 30 days)
Brian on 27 Oct 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
I'm just looking for some advice with a programming logic question. My problem in my application comes from an intersection check in a binary tree generation application. It has to do with algorithmic airway growth and checking for intersections between segments grown and modeled as cylinders.
My first bit of programming logic was as follows: grow segment, check for intersection. I check for intersections by checking a few cross products, finding the points in the cylinders that are the closest to each other, then finding the distance between them. If the distance is smaller than the sum of the two radii, they intersect. This step can take a looong time when I have thousands of segments, and this step is done every time I add a connection.
What I did then was add a search algorithm before that. Now, I check for all segments within a particular radius, and check for intersections between those. What I do is search for all segments in a sphere equal to the length of the largest segment, and check for intersections in those faces. Its better, but its still the longest compute step in my code.
I was wondering, any advice on how better to do this? Again I have two methods that work, one is slightly better, just wondering if there was a better method to save me some compute time. It can get to the point where this computation takes tens of seconds to minutes per iteration, where every other step in my generation application takes fractions of a second to a few seconds.
I'm attaching a simple m file with some calculations I made, as well as a simple m file to visualize the example. Use main.m to run the file.
If I can somehow get away from computing distances, that would be optimal. Or, perhaps, some advice on how to avoid intersections in the first place. Thanks again for any advice!

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by