1

I am trying to rotate a Rectangle2D object by a particular theta. But I cannot do this because the method transform(AffineTransform) is undefined for Rectangle2D. Any thoughts on how to do this? Thanks.

Rectangle2D.Double currentVehic = new Rectangle2D.Double(bottomLeft[0], bottomLeft[1],vehicWidth, vehicHeight);
    // Rotate the vehicle perimeter about its center
    AffineTransform rotate = new AffineTransform();
    //Rectangle2D rotatedVehic = AffineTransform.getRotateInstance(theta,x,y);
    rotate.setToRotation(theta, x, y);
    currentVehic.transform(rotate);

    return currentVehic;
user3014093
  • 369
  • 2
  • 5
  • 19

1 Answers1

5

Because a Rectangle2D is a Shape, you may be looking for the AffineTransform method createTransformedShape(). A complete example is cited here.

Community
  • 1
  • 1
trashgod
  • 200,320
  • 28
  • 229
  • 974