I'm thoroughly confused about radians and degrees! Been a long time since high school math
I'd like to get the rotation of an object (currently being returned in radians), convert that to degrees, and allow for a variance of a few degrees. So a player is rotating the object to line it up with another object, and I'm checking that the rotation is correct.
The rotation should be 180 deg, give or take a few degs (so 175 to 185 deg).
However, my rotation is converting as where approx 185 is shows up as -175... Basically once it hits 180 it converts into a negative number, backwards from 180.
I've got
this.rot = rotationOfSprite;
var degs = this.getDegrees(this.rot);
console.log(degs);
getDegrees: function(){
var degs = this.rot * 180/Math.PI;
return degs;
}
SOLVED. Figured it out. Thanks (future ref: if(this.rot<0) this.rot +=2*Math.PI.