How to rotate a vertex position matrix with angle-axis input

dtr's icon

Hi,
I haven't been able to work this one out. How do I rotate a matrix with XYZ position data with an angle-axis vector (a,x,y,z) as input? Is there an external that does this?

Tanx, D.

dtr's icon

Ok I found one solution in Graham Wakefield's quat externals: [axis2quat] and [quatpov]. This forces me to to iterate through the matrix cells though. Is there a solution that transforms the matrix data directly? With the right math code I could make a jit.gen operation as well.

mark2e's icon
dtr's icon

I should be able to max-ify that. Tanx!

Rob Ramirez's icon

couple things to mention.
there are max 6 native versions of the quaternion objects.
jit.quat
jit.quat2euler
jit.euler2quat
jit.quat2axis
jit.axis2quat

if your matrix of vertices came from an jit.gl object in matrixoutput mode, you can apply a rotation to the object itself and use @matrixoutput 2, to output the transformed vertices.

but otherwise, you should be able to construct a gen patch that takes a quaternion as a parameter, and transforms the vertices appropriately.

dtr's icon

tanx!

> if your matrix of vertices came from an jit.gl object in matrixoutput mode, you can apply a rotation to the object itself and use @matrixoutput 2, to output the transformed vertices.

I know but this is exactly to work around the lack of matrixoutput in jit.gl.mesh...

Julien Bayle's icon

dtr, I'm interested, by your final solution.
jit.gen ?

dtr's icon

Hey, I didn't implement it yet. It's on my list for optimization steps but got more pressing issues right now...

Julien Bayle's icon

argh :)
all forces with you!

on my side, playing with quaternions.. I'll post my stuff soon

dtr's icon

Thanks! 4 days till graduation exam performance, gotta weave all those loose threads together in a solid fabric...