Thanks a million, its workin pretty well but may need tweaking. One thing tho, at 0 radians its drawing a vertical line. I thought it would be horizontal at 0, 180 etc.
Basically the user can input desired angle of a shot. I want this to be vertical at 90, horizontal at 0, and have everything in between. Will i need a conversion to degrees, or something like that?
Thanks again, much appreciated.
D.
One more quick question.
When the angle in degrees passes 90, say its 135 i want it pointing north west, i convert this to radians, and then pass it into the relevant cos and sin functions, but its animating it north east... is this down to the radians or am i just missing something? probably the latter.. ;)
Thanks Again,
D.
This works:
g.drawLine(x,y,
(int)(x+Math.cos(degrees/180.0*Math.PI)*length),
(int)(y-Math.sin(degrees/180.0*Math.PI)*length));
/180*Math.PI might be replaced with a call to Math.toRadians() if you dont want to support 1.1
Plus, you can be way more accurate with radians.
I understand what you're saying. I'm a sucker for measuring angles in degrees then converting, infact all my rotation methods take the angle in degrees then convert to radians(: S). In my case I use them just because (at the moment) its easier to visualise, but I am trying to convert. It's all new to me this maths lark :)
From now on a circle is not 360 degrees its 2*Math.PI.
It may have to do in part with the educational system here (USA). Every protractor I have ever seen in any school uses degrees to measure the angles, and geometry is first taught from the perspective of degrees rather than radians, so it is possible that the preference is built-in that way. That, and dealing with whole numbers always seems simpler than fractions, especially when you're talking about computer programming and the limitations of representing such numbers in the computer.
I guess it's all in what you're used to.
-Dok