# Thread: Rotating image based on the direction of a line

1. Member
Join Date
Aug 2009
Posts
9
Rep Power
0

## Rotating image based on the direction of a line

Hello,
My question really has more to do with math than Java; although, I'm trying to rotate a buffered image using rotate(double theta) from Graphics2D based on the direction of point A to point B.
[Graphics2D (Java 2 Platform SE v1.4.2)

Could someone provide the equation? Also, if there's a better way of doing this, please do tell.

Thanks.

2. You have to define the phrase "based on the direction of point A to point B" a bit better.

kind regards,

Jos

3. Member
Join Date
Aug 2009
Posts
9
Rep Power
0
Originally Posted by JosAH
You have to define the phrase "based on the direction of point A to point B" a bit better.

kind regards,

Jos
I created an image to illustrate what I want to do; hopefully it'll help. The box represents the image. I would like the south part of the box to be parallel with the line.

http://img831.imageshack.us/img831/7606/examplehp.png

4. Originally Posted by YellowPainting
I created an image to illustrate what I want to do; hopefully it'll help. The box represents the image. I would like the south part of the box to be parallel with the line.

http://img831.imageshack.us/img831/7606/examplehp.png
Understood; now you have to define the centre of your rotation. The angle of the rotation is defined by the slope of the line.

kind regards,

Jos

5. Member
Join Date
Aug 2009
Posts
9
Rep Power
0
Originally Posted by JosAH
Understood; now you have to define the centre of your rotation. The angle of the rotation is defined by the slope of the line.

kind regards,

Jos
Thanks, helped a lot.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•