360degree rotation in Java2D

W

Will Clark

I have a bit of a problem rotating Shapes using the Graphics2D function
rotate(theta).

My high-school trig lessons indeed tell me that sine and cosine functions go
between -90 degrees and +90 degrees (or 0 and 180, if you like), and I can
see why this means that when I call the rotate(...) function, it will not
rotate the object all the way round the whole 360 degrees.

Currently, I have a duplicate Shape object which is flipped so that for one
half of the rotation the original shape is drawn, and for the second half,
the other...

There must be a better way!

Any ideas?

Cheers :eek:)

Will
 
W

Will Clark

Yep, sorted now!

Cheers again, it was in the use of the Math.atan function... grrr, silly
mistakes!
 
R

Roedy Green

Cheers again, it was in the use of the Math.atan function... grrr, silly
mistakes!

Mathematically arctan has many possible solutions. Any atan
implementation has to pick a range for its canonical solutions to fall
in.
 
K

Knute Johnson

Will said:
Yep, sorted now!

Cheers again, it was in the use of the Math.atan function... grrr, silly
mistakes!

Remember that Math.atan returns theta in -pi/2 to pi/2 and that
Math.atan2 returns theta in -pi to pi.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,831
Latest member
HealthSmartketoReviews

Latest Threads

Top