I know this isn't a hard trig issue, but sadly I am math retarded.
I need to draw a line of 50 pixels from a known starting point along a known angle to an unknown ending point. The angle is derived from a starting point (400,400) and a mouse click; the line needs to be drawn towards the mouse click, but only 50 pixels towards the click.
I've google'd extensively and found a number of solutions, but it's just not coming together for me.
Here is how I'm getting the angle.:
float angle = (float) Math.toDegrees(Math.atan2(400 - event.getY(), 400 - event.getX()));
float angleInDegrees = (angle + 270) % 360;
"event" is a mouse click.
float endX = 250 + 50 * (float)Math.cos(angleInDegrees);
float endY 250 + 50 * (float)Math.sin(angleInDegrees);
line.setStartX(400);
line.setStartY(400);
line.setEndX(endX);
line.setEndY(endY);
Everything I've found revolved around Math.cos and Math.sin but I'm still not getting it. I think the issue is related to mapping radians to scene coordinates, but I'm not sure. So people, in what way am I stupid? I'd appreciate any help.