motion

Android, help rotating image on touch

烈酒焚心 提交于 2019-12-03 04:38:34
问题 I am trying to rotate one of the transparent PNGs on this image. The number part is what I want to rotate. I am able to do this, but it is not what I am trying to achieve I want to rotate the numbers like on a real combination lock. So the user will touch and move their finger in a circle. I looked at less precise image rotation on touch/move events, and they were not sufficient. this is currently my code public boolean onTouch(View v, MotionEvent event) { double r=Math.atan2(event.getX()

What's the difference between ACTION_CANCEL and ACTION_UP in MotionEvent?

蓝咒 提交于 2019-12-03 02:33:31
I want to track a finger touch on the screen. So what I did was to start recording the position when MotionEvent triggers ACTION_DOWN , but how do I know when the action is finished, at ACTION_CANCEL , or ACTION_UP ? What's the exact difference between them? MotionEvent: ACTION_UP: A pressed gesture has finished, the motion contains the final release location as well as any intermediate points since the last down or move event. ACTION_CANCEL: The current gesture has been aborted. ACTION_CANCEL occurs when the parent takes possession of the motion, for example when the user has dragged enough

Android, help rotating image on touch

[亡魂溺海] 提交于 2019-12-02 18:55:38
I am trying to rotate one of the transparent PNGs on this image. The number part is what I want to rotate. I am able to do this, but it is not what I am trying to achieve I want to rotate the numbers like on a real combination lock. So the user will touch and move their finger in a circle. I looked at less precise image rotation on touch/move events, and they were not sufficient. this is currently my code public boolean onTouch(View v, MotionEvent event) { double r=Math.atan2(event.getX()-lockNumbers.getWidth(), lockNumbers.getHeight()-event.getY()); int rotation=(int)Math.toDegrees(r); switch

How to stop responding to a shake before a button is pressed?

流过昼夜 提交于 2019-12-02 09:18:27
i am currently making a iPhone app, and a animation reacts to a small shake, this is my code: static BOOL SJHShaking(UIAcceleration* last, UIAcceleration* current, double threshold) { double deltaX = fabs(last.x - current.x), deltaY = fabs(last.y - current.y), deltaZ = fabs(last.z - current.z); return (deltaX > threshold && deltaY > threshold) || (deltaX > threshold && deltaZ > threshold) || (deltaY > threshold && deltaZ > threshold); } - (id)initWithFrame:(CGRect)frame { if (self) { // Initialization code } return self; } -(void)awakeFromNib{ [super awakeFromNib]; [UIAccelerometer

HTML5 Canvas Motion Blur effect?

孤街醉人 提交于 2019-12-01 18:26:37
I'm trying to use HTML5 canvas to make something like a motion blur effect and no success. Basically what I'm trying to do is to take a photo and make it look like "fast forwarded", like when you take a picture and the person moved. There are several libraries for canvas that have implemented various blurring algorithms. EaselJS has implemented x- and y-axis blurring independently, as you can see in this sample. All you might want is a x-axis blur from their libray. derekmc I got here with the opposite problem. I was trying to get rid of blur when scaling images. Fortunately, my problem leads

Vertical movement sensor

我们两清 提交于 2019-12-01 16:12:46
问题 I am working on an android app that requires the detection of vertical motion. When moving the tablet upward, the Gyroscope, Accelerometer, and Linear Acceleration sensors give a corresponding value indicating upward or downward motion. The problem I have is that these sensors will also read an upward/downward motion when you tilt the tablet towards the user or away from the user. For example, the x value in the gyroscope represents the vertical plane. But when you tilt the device forwards,

MatLab ODE start/stop conditions

…衆ロ難τιáo~ 提交于 2019-12-01 12:34:44
I have a small problem. I have 2 equation of motion 'ph' and 'ph2' I don´t know how to set ODE to stop calculating 'ph' when x(1)> 0.111 and then starts to calculated 'ph2' again only to 0.111, after that plot 'ph' + 'ph2' to one graph depend on time 'w' i think I have to set some time limitations but dont know how to. I use HELP but no benefit for me. [t,y] = ode45(@ph,[0,w_max],[0,0]); function dx = ph(tt,x) global F1 c m_c Ff p w s ln f_t sig dstr Ren pn Fex Fzmax xz xn l Fz mn Fpp = F1 + c*x(1); if pn<0 pn=abs(pn); end if x(1)<ln pn=spline(w,p,tt)-((2*sig)/dstr*Ren); Fex=3.1416.*f_t.*pn.*

When GPS is not available how to get notified when the phone is in motion?

别说谁变了你拦得住时间么 提交于 2019-12-01 11:48:19
I would like to detect when the phone is in motion, but not all kind of motion. For example picking up or waving the phone should not trigger. I would like ideally to run a code when the phone/person is in > "walking" state. What options I have? you can use a combination of the accelerometer and the digital compass, in phones that have them, to determine a speed and direction. If all you need to do is determine if the person is walking, all you need is the accelerometer. Just process its output for foot steps. There are plenty of tutorials on the web for detecting foot steps with an

MatLab ODE start/stop conditions

我的未来我决定 提交于 2019-12-01 11:17:13
问题 I have a small problem. I have 2 equation of motion 'ph' and 'ph2' I don´t know how to set ODE to stop calculating 'ph' when x(1)> 0.111 and then starts to calculated 'ph2' again only to 0.111, after that plot 'ph' + 'ph2' to one graph depend on time 'w' i think I have to set some time limitations but dont know how to. I use HELP but no benefit for me. [t,y] = ode45(@ph,[0,w_max],[0,0]); function dx = ph(tt,x) global F1 c m_c Ff p w s ln f_t sig dstr Ren pn Fex Fzmax xz xn l Fz mn Fpp = F1 +

When GPS is not available how to get notified when the phone is in motion?

谁说胖子不能爱 提交于 2019-12-01 09:56:39
问题 I would like to detect when the phone is in motion, but not all kind of motion. For example picking up or waving the phone should not trigger. I would like ideally to run a code when the phone/person is in > "walking" state. What options I have? 回答1: you can use a combination of the accelerometer and the digital compass, in phones that have them, to determine a speed and direction. If all you need to do is determine if the person is walking, all you need is the accelerometer. Just process its