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
Post a Comment