## Recommended Posts

I'm using a pathsolver setup (from entagma) to get some random animation on points, moving either 1 step in X or Z each iteration.  And then running into problems trying to create rotations from the animation data.  The math to get the correct amount of rotations (happening in CHOPs), seems to be working, however the orientation or the axis' that the rotations are supposed to happen on, are getting screwed up.

If I only allow for rotations along one axis, either X or Z, I can get it to work.  But when I enable both, I start getting really weird behavior, and rotations happening along different axes.  So if there's a quaternion expert out there that wouldn't mind taking a look, I'd really appreciate it.  Basically the part in the scene where I'm having issues is the pink rotations node near the bottom, and that is getting its data from the green chopnet just above.  The stuff near the top, in the grey subnet, you can pretty much ignore, it's just generating some animation on the points in a technical way.

Thanks!

pathsolver04.hiplc

• 1

##### Share on other sites

Hey loudsubs !

So, I really am not an expert on matrix or quaternions, but I managed to come up with something that works for you, even though I can not explain it very well -.-
That means that I cannot debug your setup itself, but I made a version using some VEX and a Solver

The idea is to compute the rotation that a point would have at a given frame (based on its velocity and the sphere radius) using this

```float radius = chf("radius");

// Get distance traveled from previous frame
vector prevPos = point(1, "P", @ptnum);
float zeDist = distance(@P, prevPos);

float rotation = zeDist / ((2*radius) * \$PI);```

Then, we rotate a matrix using this rotation value using this

```float angle = radians(rotation*360);
vector axis = normalize(v@dir);

// Rotate the matrix (this is only one frame's worth of rotation)
rotate(3@m, angle, axis);```

And finally, we accumulate the matrix m using the previous' frame matrix

```matrix3 prevMatrix = point(1, "m", @ptnum);
3@m = prevMatrix * 3@m;```

Notice how I specified "3@m = prevMatrix * 3@m;" instead of simply doing "3@m *= prevMatrix;" (which is the same as doing "3@m = 3@m* prevMatrix;")
I think something like this was the issue with your setup, since when I used "3@m *= prevMatrix;", my setup behaved sort of like yours
I believe this has to do with right/left multiplication order, affecting the local/global rotation or something
I encourage you to try it out, using the Visualize node to see the animated angles resulting from it

Note that this was all in a single wrangle running over Points, inside a Solver (input 0 is Current frame, input 1 is Prev_Frame)

And then I rotated the matrix by 90 degrees in Y (unsure why, but note that we are outside the Solver at this point), and we're done
Converting the matrix to orient and passing it into the copytopoints gives the right result

Hopefully there is something that makes sense in all of that !

Edited by Alain2131
• 2

## Create an account

Register a new account