Good evening folks,

I have a little project I've been working on, and have a bit of a puzzle I could use some assistance with figuring out.

It a computer graphics (hobby) thing, but it's also a logic/math issue, which I figure the Calc people ought to be great at.

I have a large grid that we can assume to be square, and that I then "roll" into a cylinder, and then bend that tube around into a circle to form --- a torus.

I'd like to trace a path around that torus as done here:

https://math.stackexchange.com/question ... to-a-torus

And that would be easy - except that I'm trying to do this by tracing the path on the square BEFORE it gets wrapped into a torus (UV mapping), and because I have a specific way I need to evaluate the function due to the nature of the grid (Bezier patches)

So, I think that the 2D pattern which would give me the correct final 3D path would be a series of diagonal lines stacked in a unit square, with the right edge of the top line corresponding with the left edge of the next line below it (or swap right with left - no matter)

I'm thinking a linear function down, and a mod(A,B) function to give the diagonal lines.

But then here's the tricky part:

I need to plot the points of this trace in each sub-square of the global grid separately, with the range in each square being 0-1 in either dimension, and need to keep track of the designation the square in horizontal and vertical directions.

So, for the folks who are following this all so far,

I have an array of Bezier bicubic patches, each with 16 control points, that are arranged into a rectangular grid.

They are numbered 0 to N1 in the horizontal direction, and 0 to N2 in the vertical direction.

I need to programmatically loop through a range of values (let's call it Theta) and know which Bezier-patch space I'm in : which array element I'm operating on.

Then, I need to start at one end of that patch, and depending upon the [i][j] location in that patch (both ranging from 0 to 1), use the field of Bernstein polynomials and control point weights to calculate the location of that point on the patch. I have already worked out the macros to do that part (with help ) and just need to figure out the system of organizing the input data for that macro, which are the "global" U,V coordinates, or the large array element designations, and the individual u,v values of each bicubic patch.

something like:

macro (U, V, u, v)

Any advice, suggestions, thoughts, solutions?

Thanks.