• Create Account

### #Actualeppo

Posted 18 December 2012 - 11:23 AM

The idea is to rotate around an axis orthogonal to the joystick vector. In a left-handed coordinate system you construct it by taking the joy / z-axis cross product:

joyAxis = normalize(cross(Vector3(joystick.x, joystick.y, 0.f), Vector3(0.f, 0.f, 1.f))) = normalize(Vector3(joystick.y, -joystick.x, 0.f)).

Next, you can either transform this vector from the camera's local space into world space. joyAxisWorld = mul(joyAxis, cameraXfrm) and then rotate around this axis by the joystick vector's magnitude:

orientation *= MatrixRotationAxis(joyAxisWorld, Vector2Length(joystick))

or you can pre-multiply the offset:

orientation = MatrixRotationAxis(joyAxis, Vector2Length(joystick)) * orientation.

### #1eppo

Posted 18 December 2012 - 09:55 AM

The idea is to rotate around an axis orthogonal to the joystick vector. In a left-handed coordinate system you construct it by taking the joy / z-axis cross product:

joyAxis = cross(Vector3(joystick.x, joystick.y, 0.f), Vector3(0.f, 0.f, 1.f)) = Vector3(joystick.y, -joystick.x, 0.f).

Next, you can either transform this vector from the camera's local space into world space. joyAxisWorld = mul(joyAxis, cameraXfrm) and then rotate around this axis by the joystick vector's magnitude:

orientation *= MatrixRotationAxis(joyAxisWorld, Vector2Length(joystick))

or you can pre-multiply the offset:

orientation = MatrixRotationAxis(joyAxis, Vector2Length(joystick)) * orientation.

PARTNERS