#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# How do I implement a random walk on a mesh in Processing?

edited February 2016

I recently wrote a Processing sketch that implemented a random walk on a sphere. I used spherical coordinates to accomplish this (see http://www.mediafire.com/view/5fgi5lsq4tc8380/sphererandwalk.jpg#). Each new segment on the random walk was defined by a previous point and a new point a random distance and direction away from the previous point.

Now I would like to see if I can apply the idea to an arbitrary 3d mesh instead of just a sphere. Instead of using straight lines to connect the points of the random walk on the sphere, I could have used geodesics to follow its surface. Geodesics can be used with 3d meshes too. Here is a paper that talks about that: http://research.microsoft.com/en-us/um/people/hoppe/geodesics.pdf. Check out figure 1. It shows geodesic paths leading from a source point on the mesh, and it also shows geodesic isolines at certain distances from a source point. I would like to do a random walk with instead of lines, geodesic paths extending from a source point to a certain random geodesic distance away in a random direction, repeatedly, with the old target point becoming the new source point for the next segment.

The above paper mentions various algorithms that can be used to calculate geodesic paths and geodesic distances. I was able to find an open source project to implement one of them: https://code.google.com/archive/p/geodesic/. The source code is written in C++. From looking at an example file, I learned that it does the following:

read mesh from file and - if one vertex is specified, for all vertices of the mesh print their distances to this vertex - if two vertices are specified, print the shortest path between these vertices

I would like to know how to interface the C++ code to Processing. Java may possibly need to be used as an intermediary, given that Processing can use Java code in a sketch. Furthermore, I would like to know what format a mesh would need to be represented in Processing in order for the geodesic C++ code to process it. In other words, how to export a mesh in Processing to the geodesic C++ code, and then import back the results.

Tagged:

• edited February 2016

Also, if there are other algorithms or techniques that are better than one I provided in the message above, I would like to know about them too. Hopefully they would be coded so that I could interface a Processing sketch to them.

• edited February 2016

Also, if there are other algorithms or techniques that are better than one I provided in the message above, I would like to know about them too. Hopefully they would be coded so that I could interface a Processing sketch to them.