matrix transformation on a simple 2d or 3d vector (list)

John J.A. Jannone's icon

Is there something in between vexpr for simple vector (list) math, and jit.mxform.. for transforming a whole matrix?

e.g. something that allows me to avoid making this in Max:

John J.A. Jannone's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Figured this one out on my own. Was not as hard as I thought (at least for 2d vectors) and was very satisfying. Here's the solution for posterity...

John J.A. Jannone's icon

And... adding the 3rd dimension is trivial.

if you are rotating about the z axis, then z=z, and the above pertains.

If you are rotating about the x axis, then use x=x, and use the formula previously used for x for y and y for z.

If rotating about y: use y=y and shift the others once more, wrapping: y to z and z to x.

The visuals from the link above help.

John J.A. Jannone's icon

Oh yeah and angle is in radians (pi radians = 180°)

yair reshef's icon
Max Patch
Copy patch and select New From Clipboard in Max.

reminds me of this jitter toy i made back in the days
https://cycling74.com/forums/inverse-kinematics

John J.A. Jannone's icon

Wow, great patch!

dtr's icon
Max Patch
Copy patch and select New From Clipboard in Max.

i've got this for rotation of matrix position data (sorry no time to put it in a nice demo patch, the XYZ rotation order might be jumbled as well)

yair reshef's icon
Max Patch
Copy patch and select New From Clipboard in Max.

i rmmbr that one from an old forum thread
here is a clearer example patch

sterlingcrispin@gmail.com's icon

thank you for sharing this!

Max Björverud's icon

I love all of you.

sterlingcrispin@gmail.com's icon

short note for anyone stumbling across this, if you're trying to do this with 3D objects using max 6 you can use jit.anim.drive that handles rotations springs and translations pretty painlessly , and most matrix types support @matrix output 2 which outputs the data after its been rotated

I built a large complicated patch in max5 before these features were around, really nice now that they're here

John J.A. Jannone's icon

Sweet thanks!

J