# Tube@BSplineCurve not mapping correctly?

(There's a tl;dr at the bottom.)

I'm attempting to do what's effectively fake branching in a random walk. I generate one random walk (in the real rather than the integers, but with steps of magnitude 1), then apply a function to it which picks a random point from which to start a new branch. If the original walk has N steps, and the random branch is chosen to start at the point m, it will extend for N - m steps such that stepping in forward in time results in that branch sprouting after m timesteps and growing simultaneously to the same length as the "source" branch.

The code is as follows (I'm sure it's suboptimal and naïve, but it seems to work):

start = FoldList[Plus, {0, 0, 0}, Normalize /@ RandomVariate[NormalDistribution[], {60, 3}]];

brancher[lopts_] := Join[lopts, {With[{pt =
RandomChoice@DeleteDuplicates@Flatten[lopts, 1]},
With[{r = Last@Position[lopts, pt]},
Normalize /@
RandomVariate[
NormalDistribution[], {Length@First@lopts - Last@r, 3}]],
Length@First@lopts, {Extract[lopts, r]}]]]}];

branches = Nest[brancher, {start2}, 15];

colorTab = Table[ColorData["Rainbow", i/(Length@branches - 1)], {i, 0, Length@branches - 1}];


This will generate a a list of 16 "branches", each nominally of length 61, though branches aside from the starting walk have fewer than 61 unique entries. (I'm having trouble exporting this data properly, oddly, but the code runs very fast even on my fanless laptop.)

The problem comes when I try to visualize the evolution of these walks in time. I do that with the following code:

Manipulate[Graphics3D[{colorTab[[#2[[1]]]], Line@#1[[;; i]]} &~MapIndexed~branches, Boxed -> False], {i, 2, Length@start, 1}]


Manipulating on i steps through time, with each unique branch assigned its own color (click for animations if it doesn't happen automatically):

(This example is weighted, but that doesn't change anything.)

You can do the same thing using Tube instead of Line (ignoring the spurious dots where the branches will occur):

Or BSplineCurve:

But combining the two, i.e. replacing Line in the above code with Tube@BSplineCurve, does not display anything but the first branch:

I have no idea why this should be; as far as I can tell, I'm mapping Tube@BSplineCurve to several lists of points, so it doesn't feel like either Tube or BSplineCurve is being supplied with the incorrect number of arguments. I haven't been able to find anything with a search and this is killing me.

Is this a known or at least replicable glitch, or have I missed something?

EDIT: Indeed, removing the Graphics3D wrapper shows that the input seems reasonable:

It seems that the repeated points at the beginning of your additional walks cause the problem. DeleteDuplicates is your friend:
Manipulate[

BTW, I've changed start2 to start in your code to make it work.
• I've seen similar problem when sent duplicated points as the input of BSplineCurve Apr 27, 2017 at 9:28
• Yep, that totally fixed it. (It also makes it so the Tube-only version doesn't have the spurious/time-traveling intersection dots!) It's so simple, but I just didn't think about it given the fact that the BSplineCurve itself didn't seem to mind the duplicates! Thanks for the smart problem-solving. Apr 27, 2017 at 16:40