I am trying to create a method (for robocode) that draws a rotatable rectangle with the (X,Y) coordinates referring to the center of rotation. I have created a method stub, but cannot figure out the actual math for the problem.
//draws a rectangle centered on (x, y) with h heading in degrees, 0 is up, 90 is right. Sides are of length l and of height w public static void drawRotatedRect(Graphics2D g, double x, double y, double h, double l, double w, Color c) { Color returnColor = g.getColor(); g.setColor(c); //draw four sides using Graphics.drawLine()? g.setColor(returnColor); }
What mathy shenanigans can I use to calculate the XY's of the four corners, so I can pass them into Graphics.drawLine()? Thanks in advance