android - rotating a matrix in one direction -


is there way make image matrix rotates in 1 direction ie: anti-clock wise ?

this rotate function

void rotate(int x, int y) {          this.matrix.postrotate((float) (this.startangle - this.currentangle),                 x, y);     } 

and ma ontouch event

case motionevent.action_move:              ring_gear.setcurrentangle((float) ring_gear.getangle(                     event.getx(), event.gety()));             ring_gear.rotate(ring_gear.width / 2, ring_gear.height / 2);              ring.setimagematrix(ring_gear.matrix);              ring_gear.startangle = ring_gear.currentangle; 

you're doing postrotate. concats previous rotation current, adding angle rotation on every move event.

if understood you're trying correctly (move ring position of finger), need set rotation of ring, not add it.

replace line:

this.matrix.postrotate((float) (this.startangle - this.currentangle), x, y); 

to this:

this.matrix.setrotation((float) (this.currentangle), x, y); 

no need continuously add angle, set is.

note:

also, pay attention angle type conversion. if i'm not mistaken, matrix uses degrees calculate rotation. i'm not sure how you're converting x/y of touch angle, if you're using math.atan2, should remember atan2 uses radians, , need sure convert angle type degrees before passing matrix.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -