From: Farhan Satria on 11 Jun 2010 22:30 Hi all.. I need some help in here. I'm trying to move 3d figure in matlab with my wiimote so it can roll and pitch. I'm using Wiilab (http://netscale.cse.nd.edu/twiki/bin/view/Edu/WiiMote). I success to move the 3d figure with a wiimote but it's not perfect. When wiimote's rolling 90 degree (or -90 degree) from starting position (wiimote at the table, pointing towards object at the screen), the object doesn't move as i expect. And it happens too if wiimote's pitch 90 degree (or -90 degree). I put my script in here: global wm; addpath C:\'Program Files'\WiiLab\WiiLAB_Matlab\EG111-H addpath C:\'Program Files'\WiiLab\WiiLAB_Matlab\WiimoteFunctions [X,Y] = meshgrid([-2:.25:2]); // example Z = X.*exp(-X.^2 -Y.^2); // of 3d surf(X,Y,Z) // object wm=Wiimote(); wm.DisconnectAllWiimotes(); wm.Connect(); view([0 1 0]); axis vis3d; camup('manual'); wm.GetAccelState(); X=wm.Accel.X; Y=wm.Accel.Y; Z=wm.Accel.Z; sx=atan2(X,Z)*180/pi; sy=atan2(Y,Z)*180/pi; if wm.isConnected() while ~wm.Buttons.A // press A to quit wm.GetAccelState(); X=wm.Accel.X; Y=wm.Accel.Y; Z=wm.Accel.Z; sx1=atan2(X,Z)*180/pi; sy1=atan2(Y,Z)*180/pi; dtheta=sx1-sx; dphi=sy1-sy; sx=sx1; sy=sy1; camorbit(dtheta,dphi,'data',[0 1 0]); // to perform roll and pitch wm.GetButtonsState(); end; end; close all ----------------------------------------------------------------------------------------------- i know the object act strange because i use atan2.. maybe it will act fine if i use euler's angle. but i don't know how. please someone help me fix my script. thanks..
|
Pages: 1 Prev: Random Generator through mex Next: Finding the index of an element in a cell |