java - What does casting a theta(angle) to float do to amount? -


in android studio i've been working on getting imageviews rotate , face coordinates. using atan2 i've set rotation of imageview this.

imageview.setrotation((float)   atan2(imageview.gety()-<coordinate y wanted face>,       imageview.getx()-<coordinate x wanted face>)  ); 

i noticed everytime ran line of code faced same direction each time.(the direction facing in drawable resource, , yes method runs actully works)

so casting result of atan2(theta result) float cause lose value or something?

i know can use matrix if have to, i'm experimenting more efficient code.

edit: turns out atan2 returns in radians...(1 radian=57.3 degrees )

the return value of atan2() in radian, while parameter taken setrotation() should in degree.

you should change into

imageview.setrotation((float)math.todegrees(atan2(..., ...))); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -