I’m trying to generate a mesh along a path in 3d space.
The path can have any shape (I’m trying to generate trees)
I keep running into issues where the points of my mesh suddenly rotate 180° compared to the previous node of the path, this results in an unusable mesh(not a mesh but a mess, hahah)
I found the algorithm (parallel transport) that could fix my issue
I found an implementation including an example in C++ which would be be of great help… but I have no experience with C++
the math of Parallel Transport is difficult for me to wrap my head around (and I have much trouble reading formulas as I have no education to help me with this)

I feel like this is a huge ask but if there’s someone here who could translate this implementation and provide me with a working demo project of parallel transport in Codea … I would be very grateful as it would help me greatly in realizing my dream of generating 3d digital plants! …and much more!

the C++ implementation can be found here:

I have trouble even describing the exact thing I require… but what I think I need is an algorithm that takes a path and returns 3 vectors(for x,y and z) that I can multiply my original points x,y and z by in order to get the a position relative to the path node which is “parallel” to the previous node.

perhaps more clearly(or just more confusingly…) what I need is a way to take a set of points in a normalized coordinate space (where x = the angle around the path, y = the distance traveled along the path and z = the distance outward from the path) and wrap these points around a curved path, ideally with smooth interpolation(catmull-rom spline*) for points whose y(distance along the path) falls somewhere between path nodes.

function crSpline(p0,p1,p2,p3,t) --return point t on a catmull–rom spline
return((2*p1)+(p2-p0)*t+(2*p0-5*p1+4*p2-p3)*t^2+(3*p1-p0-3*p2+p3)*t^3)/2
end

My roller coaster program (which is in the Codea examples) uses parallel transport to orient the track as it goes around the defining path.

First question, is your path open or does it return to its starting point? The latter adds a small complication if you want the transportation to also return to its starting point.

generally my path would be open, I imagine for a closed path a gradual rotation would have to be added over the length of the path so the ends line up.
I would love to see your roller coaster project, such a perfect use case for parallel transport!

oh …I just somehow missed that it’s in the examples ?!
the answer has been so close all along

I looked at the example, it’s difficult for me to find where the parallel transport is happening… is it the tangent function…?
will look at it more closely tomorrow… hopefully it’ll make sense to me…
although I see quaternions so I doubt it will

@Amber just out of curiosity, is there a reason beyond giving yourself a challenge that you don’t want to use the tree generators available in Codea? There’s code around these parts that will generate trees for you with all kinds of customization including foliage size and density and etc.

I necessarily must give myself this challenge lol,
I have looked around for tree generators and haven’t found one with all the features I’m looking for:
• 3 dimensional
• …actually 4 dimensional because it must grow over time
• highly customizable
• works with mesh instancing (I need many trees!)
• an individual tree must be saved with just a few values (pos,age,seed,species)

Note the project will crash at launch but if you just hit the ‘play’ button at the bottom it will run just fine and you can play with all the parameters in real time.

As to your checklist:

• 3 dimensional - check
• …actually 4 dimensional because it must grow over time - not as such, but this should be fully implementable by coding parameter changes
• highly customizable - customizable out the wazoo, really
• works with mesh instancing (I need many trees!) - not fully clear what you mean here but I think the answer is yes, it does this
• an individual tree must be saved with just a few values (pos,age,seed,species) - well you don’t get highly customizable with just a few values, but yes any given tree comes from a list of parameters easy to store and retrieve

…this isn’t original by the way, it’s just a Codea port of a tree generator called ProcTree that’s been around a long time.

Did you hit the play button at the bottom of the screen? I’m using the latest beta. For me it launches to just a blue sky and an error message in the console but if I hit the play button the tree appears.

Don’t know what to tell ya. So you can scroll around and everything, the OrbitViewer camera is working?

Have you tried maybe zooming in a lot or out a lot?

Here’s an odd thought: maybe for some reason the JavaScript module isn’t working for you? The errors that come up are all linked to JavaScript, I think, and the project is supposed to include all the JavaScript stuff in it, but maybe it’s not being seen for some reason? Like maybe did you reorganize the order of the tabs?

I’ll have to try it on my iPad; I only know for sure it’s been working on my iPhone.