Math/src/main/java/com/techshroom/tscore/math/Maths.java
public static Rectangle2D rotateRect(Rectangle2D r, double theta) {
			// store data
			double x = r.getX(), y = r.getY(), w = r.getWidth(), h = r
					.getHeight();
			// clear rect
			r.setRect(0, 0, 0, 0);
			// get points
			Point2D[] points = new Point2D[] { new Point2D.Double(x, y),
					new Point2D.Double(w + x, h + y) };
			// calc cos/sin
			double s = TrigTableLookup.sin(theta), c = TrigTableLookup
					.cos(theta);
			// expand rect to fit
			for (Point2D p : points) {
				p.setLocation((p.getX() * c) - (p.getY() * s), (p.getX() * s)
						+ (p.getY() * c));
			}
			r.setRect(points[0].getX(), points[0].getY(), points[1].getX()
					- points[0].getX(), points[1].getY() - points[0].getY());
			return r;
		}
/**
		 * Rotates the given rectangle by <code>theta</code> degrees, treating
		 * it as if it were drawn at that angle and not axis-aligned.
		 * 
		 * @param r
		 *            - the original rectangle
		 * @param theta
		 *            - the rotation angle
		 * @return <code>r</code>, rotated by <code>theta</code>
		 */
Rotates the given rectangle by theta degrees, treating
it as if it were drawn at that angle and not axis-aligned.

@param r
- the original rectangle
@param theta
- the rotation angle
@return r, rotated by theta
Rotates the given rectangle by theta degrees treating it as if it were drawn at that angle and not axis - aligned . @param r - the original rectangle @param theta - the rotation angle @return r rotated by theta
public static Rectangle2D rotateRect(Rectangle2D r, double theta) {
			double x = r.getX(), y = r.getY(), w = r.getWidth(), h = r
					.getHeight();
			r.setRect(0, 0, 0, 0);
			Point2D[] points = new Point2D[] { new Point2D.Double(x, y),
					new Point2D.Double(w + x, h + y) };
			double s = TrigTableLookup.sin(theta), c = TrigTableLookup
					.cos(theta);
			for (Point2D p : points) {
				p.setLocation((p.getX() * c) - (p.getY() * s), (p.getX() * s)
						+ (p.getY() * c));
			}
			r.setRect(points[0].getX(), points[0].getY(), points[1].getX()
					- points[0].getX(), points[1].getY() - points[0].getY());
			return r;
		}
public static Rectangle2D rotateRect ( Rectangle2D r , double theta ) { double x = r . getX ( ) , y = r . getY ( ) , w = r . getWidth ( ) , h = r . getHeight ( ) ; r . setRect ( 0 , 0 , 0 , 0 ) ; Point2D [ ] points = new Point2D [ ] { new Point2D . Double ( x , y ) , new Point2D . Double ( w + x , h + y ) } ; double s = TrigTableLookup . sin ( theta ) , c = TrigTableLookup . cos ( theta ) ; for ( Point2D p : points ) { p . setLocation ( ( p . getX ( ) * c ) - ( p . getY ( ) * s ) , ( p . getX ( ) * s ) + ( p . getY ( ) * c ) ) ; } r . setRect ( points [ 0 ] . getX ( ) , points [ 0 ] . getY ( ) , points [ 1 ] . getX ( ) - points [ 0 ] . getX ( ) , points [ 1 ] . getY ( ) - points [ 0 ] . getY ( ) ) ; return r ; }
Rotates the given rectangle by <code>theta</code> degrees, treating
 it as if it were drawn at that angle and not axis-aligned.
Rotates the given rectangle by <code > theta< / code > degrees treating it as if it were drawn at that angle and not axis - aligned .
// store data // clear rect // get points // calc cos/sin // expand rect to fit