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.

Printable View

- 08-22-2012, 06:12 AMlolmisterSmooth 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.

- 08-22-2012, 06:23 AMFubarableRe: Smooth rotation to a desired direction
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. - 08-22-2012, 06:31 AMlolmisterRe: 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:

Code:`if(currentrotation>desiredrotation)currentrotation-=1;`

else currentrotation+=1;

- 08-22-2012, 06:37 AMFubarableRe: 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.

- 08-22-2012, 06:40 AMlolmisterRe: Smooth rotation to a desired direction
Ok, thanks for the tips

- 08-22-2012, 10:17 AMDarrylBurkeRe: Smooth rotation to a desired direction
Moved from Advanced Java

db