Graphics2D g2d=(Graphics2D)g g2d.translate(150, 0); g2d.rotate(1); // Rotate the image by 1 radian. g2d.drawImage(image, 0, 0, 100, 100, this);
However I am at a loss as for how to rotate an image dependant on where my mouse is at.
For example, I use this:
//instance variables declared above xpos = (m.getXOnScreen()-5); ypos = (m.getYOnScreen()-50);
to get the position of the mouse on the screen but I am unsure as to how to work out an angle for this value, I have thought of maybe using cosine rule:
c = square route(xpos^2+ypos^2-cos(xpos*ypos*cos(C))
to no avail, if anyone could point me in the right direction as to how I could rotate the BufferedImage by X degrees, even just a general method or some pseudo-code that I could then try to implement it would be greatly appreciated.
tl;dr: I am stuck mainly because I cannot figure out as to how one would get an angle between two co-ordinates on the monitor
Are there any libraries that can do this calculation for me or must I continue trying to figure it out?