Object Rotation And Joystick Maths
Looking for some SOH CAH TOA Wizards to help me out here
I'm looking to use a joystick to rotate an object. I am using the unit circle with x/y values between -1 and 1. I can get the x and y values and use acos to find the proper angle,
Here's my problem...Instead of having the angle of rotation be 90 degrees when x =0 and y=1
is there a way to rotate the circle with maths or something to make it so when x=0 and y=1 the degrees come out to be 0
This would make sense from a joy stick perspective...
i might not understand completely(don't-know/can't-picture the exact interface), but maybe you could try 'asin' instead of 'acos'? (this will rotate by 90º)
Okay...That's a little bit closer thank you so much.
Okay...Think about it like this. I am trying to aim an object in a certain direction based on a joystick direction. Think about how a video game character moves. You push the joystick forward and the angle of the character is 0. Push the joystick all the way right the angle is 90 degrees...etc.
The maths to do this seem to emulate lookat attribute for the jit.gl.camera (when tripod is enabled) if I could just get those same maths onto a jit.gl.gride shape (no lookat attribute) from a joystick input that would do the trick
ya, no worries about the joystick facing forward part, but i don't trust myself to be able to imagine the whole interface of Max objects without seeing the patch(there are many ways you could be working with the input... poltocar~ help file shows other math that could be used...)... when you plugged 'asin' into your patch instead of 'acos', did it work or how was it off?
edit:
i'll try to look further at the gl.camera stuff later, but if you can post a patch that'd help more, otherwise, just mentioning that there's also a 'cartopol' object in gen if that can help at all(maybe you can scale and rotate either the input or the output there, too)
It does the job perfectly for half of the angles, but doesn't work because It cannot handle some number combinations...
I am using an xbox controller as the input device so if I could rotate an object like in a video game using the xbox controller as an input device that would be amazing. I know it's a number remapping problem.
The joystick controller for the xbox I have mapped on the x and y plane from -1 to 1
Sounds like adding/subtracting an offset then wrapping the value with [pong] could be a solution. This example uses degrees but can be modified to handle radians or other arbitrary values.