title: Rotating a Rectangle from any point
body: <p>I'm trying to write a script (javascript) in an API of a Virtual Table Top program so I can manipulate some tokens (Car Wars :)).</p>
  
  <p>I'm sort of finding the answer, but it seems like I'm struggling and reinventing the wheel so I thought I'd ask for help.  One reason I'm getting confused is the program returns results based on +y is down and Deg go clockwise which is different than what all the trig formulas want (counter clockwise and +y is up).</p>
  
  <p>Here is what I have access to.  Rectangle rotates around centre, Centre point(x,y), width, height, and rotation.  I've got the code working for moving the rectangle in the direction of the rotation, side to side, up and down, etc.  Now I need to be able to rotate it around any of the four corners or any point would be nice, but four corners are all thats needed.</p>
  
  <p>It won't let me include an image since I'm new so I hope the description is good enough.  I had an image all done up. :(</p>
  
  <p>In the API I can't actually draw the rectangle, I can only set its rotation, and centre value.  So my thought was if I can find the x,y of one corner currently, then rotate it the desired degs around the centre (I can do this easily by setting the rectangles rotation), find the new x,y of that same corner.  Then I will know the offset and apply that to the centre (thats how the rectangle is moved as well).</p>
  
  <p>So I need to be able to find the x,y of any corner of a rectangle at any given starting angle, then again at a new angle rotated at its centre.  This offset would then be easily applied to the centre x,y and the rectangle would see to have rotated along one of its corners.</p>
  
  <p>Thanks for any help you can give.  I'm hoping I will eventually figure it out, just writing this description out actually has helped me think it through.  But I'm currently stuck!</p>
  
  <p>Konrad</p>