public static BufferedImage spinning(Image img, double fDegree) {
		BufferedImage bufImg = convert(img);
		BufferedImage resultImg = new BufferedImage(bufImg.getWidth(),
				bufImg.getHeight(), BufferedImage.TYPE_INT_RGB);

		// get height and width
		int height = bufImg.getHeight();
		int width = bufImg.getWidth();

		double midX = width / 2;
		double midY = height / 2;

		int ynew = 0;
		for (int j = 0; j < height; j++) {
			double trueY = ynew - midY;
			int xnew = 0;
			for (int i = 0; i < width; i++) {
				double trueX = xnew - midX;

				double theta = Math.atan2(trueY, trueX);
				double radius = Math.sqrt(trueX * trueX + trueY * trueY);
				double degree = theta + fDegree * radius;
				int x = (int) (midX + radius * Math.cos(degree));
				int y = (int) (midY + radius * Math.sin(degree));

				// for debugging System.out.println(" ");
				// put the colour of x,y pixel from the original image to the
				// xnew,ynew pixel of the buffered image
				if (x >= 0 && y >= 0 && x < width && y < height)
				// if(xnew>=0 && ynew>=0 && xnew<width && ynew<height)
				{
					int values = bufImg.getRGB(x, y);
					// int values = bufImg.getRGB(xnew,ynew);
					Color color = new Color(values);
					resultImg.setRGB(xnew, ynew, color.getRGB());
					// resultImg.setRGB(x, y, color.getRGB());
				} else {
					// System.out.println("x: "+x+"  y: "+y+" "+trueX+" "+trueY+" "+midX+" "+midY+" "+theta+" "+radius+" "+degree);
					int values = bufImg.getRGB(i, j);
					Color newColor = new Color(0, 0, 255); // for debugging
					resultImg.setRGB(xnew, ynew, newColor.getRGB());// for
																	// debugging
					// Color color = new Color(values);
					// bufImg.setRGB(xnew, ynew, color.getRGB());
				}
				xnew++;
			}
			ynew++;
		}
		return resultImg;
	}