I want to make a Gradient Descent algorithm which iteratively performs small steps in the direction of the negative gradient towards a (local) minimum (like a drop of water on a surface, flowing downwards from a given point in the steepest descent direction). Does anyone know how to do this?
One Quick Question the script in your built:
I wonder how this is working mathmatically:
GradDir = New On3dVector(ddu.x * ddu.z + ddv.x * ddv.z, ddu.y * ddu.z + ddv.y * ddv.z, 0)
it seems this does the "rotate normal along product" step very quickly.
Well, I haven't found the problem yet, but I'm pretty sure that it's to do with the recursive nature of the code. Recursion is a fantastic way to get massive, immediate crashes with zero information and zero chance of rescue.
I also just wrote a recursive pathfinding code and Im having a similar issue. Is there something Im missing that may catch the error or prevent the crashing? Even when i change a variable slightly sometimes it will crash. I think if i can get over this hump I wont have to bother anyone on the forum much more. ;) Thanks for your time.
Since you don't need recursion here (a drop of water never splits into two streams, so this is a perfect iterative process), I suggest you don't use it.
I attached a script with an iterative method and also a bunch of extra error trapping.
I"m trying to run the script, but the output is still Null on the curves, And i've follow the line of codes from the previous versions of this and i'm still not sure why exactly the output would be null in this case. Any idea?