```
public void rotate(double theta)
{
// this is the matrix to multiply by..
//x*cos(theta) , y* sin(theta)
// x* -sin(theta)
//y * cos(theta)
vertices[0][0]= vertices[0][0]* Math.cos(theta)+ Math.sin(theta)*vertices[0][1];
vertices[0][1]= vertices[0][0] * (-Math.sin(theta)) + Math.cos(theta)*vertices[0][1];
vertices[1][0]= vertices[1][0]* Math.cos(theta)+ Math.sin(theta)*vertices[1][1];
vertices[1][1]= vertices[1][0] * (-Math.sin(theta)) + Math.cos(theta)*vertices[1][1];
vertices[2][0]= vertices[2][0]* Math.cos(theta)+ Math.sin(theta)*vertices[2][1];
vertices[2][1]= vertices[2][0] * (-Math.sin(theta)) + Math.cos(theta)*vertices[2][1];
vertices[3][0]= vertices[3][0]* Math.cos(theta)+ Math.sin(theta)*vertices[3][1];
vertices[3][1]= vertices[3][0] * (-Math.sin(theta)) + Math.cos(theta)*vertices[3][1] ;
}
```

michael.james.90475
-3
Newbie Poster

## Recommended Answers

Jump to PostWhere is the centre of rotation (is it the top left corner?)

Jump to PostI guess that rotates about the 0,0 origin of your coordinate system.

If you want to rotate about (say) the center of the object you can:

translate the object so the centre of the object is at the origin

rotate the object

translate it back to the original position

(translation …

## All 8 Replies

michael.james.90475
-3
Newbie Poster

JamesCherrill
4,394
Most Valuable Poster
Moderator
Featured Poster

JamesCherrill
4,394
Most Valuable Poster
Moderator
Featured Poster

michael.james.90475
-3
Newbie Poster

michael.james.90475
-3
Newbie Poster

JamesCherrill
4,394
Most Valuable Poster
Moderator
Featured Poster

michael.james.90475
-3
Newbie Poster

michael.james.90475
-3
Newbie Poster

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.