## Re: [max-msp] faking jit.gl.handle autorotate

May 16 2006 | 4:19 pm
Coming back on this old post I never got a reply to...Not that I've spent a whole year on this but I still can't figure it out:-)
If you use the mouse input to autorotate a jit.gl.handle all axis are rotating most of the time. How is this calculated? I can't get my head around it. I guess the mouse input generates a vector that is used to compute the rotation and speed on every axis, but how?
I'd like to store/recall the vector and speed to compute the rotate or rotatexyz parameters without using jit.gl.handle and without actual mouse input. Can someone with better math skills help me out please?
-thijs

• May 16 2006 | 4:40 pm
Hi Thijs, Try this patch out. It's really basic, but a start. The next modification I would make would be to add the ability to change rotation speed on the fly and not just at the end of a revolution as it now stands.
best, wes
• May 16 2006 | 6:01 pm
Hi Wes, from what I understand your approach is similar to the one I use right now (rotating one axis - the other 2 fixed offsets - moving the camera around). The problem is that using the mouse input on a handle, there are 3 axis involved in the rotation. Your patch doesn't explain to me how to generate a rotation like that. (without moving around the camera/scene)
I think this is more obvious looking at a plane then a torus. Forgive me if I'm being stupid, but I don't know how I can explain myself otherwise.
best, -thijs
• May 16 2006 | 6:09 pm
HI Thijs,
I'm not sure if the Jitter3DUtils or even JavaScript support was available when you first asked your question. But now the answer is simple: use the quaternion rotation code from the Jitter3dUtils. Keep track of your rotation as a quaternion, accumulating it with add_quats. Use quat_to_axis to convert into axis/angle format. Plenty of intro-to-quaternions stuff from the gave development world should be available through Google.
best Randy
• May 16 2006 | 6:14 pm
The JS3dutils xyz_to_quat is a good place to look for what Randy is talking about. In the previous patch, you can add more rotation by the following:
• May 16 2006 | 6:15 pm
Hey Thijs,
I'd suggest looking at both the Jitter3DUtils.js (c74:/js-extensions) and the topic on joyrotate/nudgexyz which has some of these things duplicated, but provides a nudgexyz method.
We could add this in a future version of Jitter3DUtils.js
-Joshua
• May 16 2006 | 8:18 pm
Thanks guys! that's exactly what I need. Last time I looked at Jitter3DUtils I didn't understand anything so I couldn't remember whats in it either. Quaternions is still a bit blurry but I'm getting there. The nudgexyz code will definitely get me going. Thanks again.
Best, -thijs
• May 16 2006 | 9:09 pm
In case someone else cares to learn about quaternion rotations... I found this really clear and helpful
-thijs