# Thread: Smooth rotation to a desired direction

1. Member
Join Date
May 2012
Posts
11
Rep Power
0

## Smooth rotation to a desired direction

I have an image with two variables, current direction, and desired direction. I want the Image to smoothly rotate to the desired direction with momentum, but I can't figure out a way to do this myself, andy help would be appreciated.

2. ## Re: Smooth rotation to a desired direction

Originally Posted by lolmister
I have an image with two variables, current direction, and desired direction. I want the Image to smoothly rotate to the desired direction with momentum, but I can't figure out a way to do this myself, andy help would be appreciated.
I can't imagine that we're going to be able to help you much based on this post above as it is way too short on details. Care to show us what you've tried so far? Can you give us a little context? Is this using BufferedImages and Graphics2D, JOGL graphics? Something completely different? Where specifically are you stuck? Come on, please help us out here.

3. Member
Join Date
May 2012
Posts
11
Rep Power
0

## Re: Smooth rotation to a desired direction

sorry, I am using BufferedImages and Graphics2D. I can rotate the image, I just need help getting the rotation smooth. I have tried to have the Image rotate a certain amount every update towards the goal rotation like this:
Java Code:
```if(currentrotation>desiredrotation)currentrotation-=1;
else currentrotation+=1;```
This doesn't compensate for the gap between 0 and 360, and the rotation doesn't have momentum so I am not happy with it.

4. ## Re: Smooth rotation to a desired direction

You have to expect discrete results when you use ints and degrees. Instead use a double variable and radians in your rotation matrix, and use a rotation step of < 1 degree (equivalent to Math.PI / 180 in radians). I assume that you're using an AffineTransform for your rotation. Play with your code and you'll likely smooth things out.

5. Member
Join Date
May 2012
Posts
11
Rep Power
0

## Re: Smooth rotation to a desired direction

Ok, thanks for the tips

db