I have a similar problem. For a school project I'm writing a 2D Rigid Body Physics Engine in
Java.
In order to simulate torque, I'm using AffineTransform.setToRotation(). Torque spins around the center-point, so I have
pos being a Point2D object, and .x and .y being the x and y coordinates of the rectangles center-point (found using getCenterX() and getCenterY().
This all works fine right up to the point where I assign a velocity vector to the rectangle, i.e. change pos.x and pos.x each time-step. As soon as I do this the rotation goes loopy, it doesn't rotate around the center-point anymore, but only close to the center-point.
I can't
test whats going wrong because I use a Shape object to allow for AffineTransform.createTransformedShape();, and there are no getCenter() methods for Shape objects.
I tried using getRotateInstance to hopefully keep my rectangles as Rectangle2D objects and so be able to see whats happening with the center-point, but when I use getRotateInstance, rotation gets even loopier.
Here's my code, just to get a better idea of what I'm talking about. I have two rectangles, RectA and RectB, and hence two of each variable. To witness the loopiness, simply change any of the velocityA/B values to anything other than 0, positive or negative. 3 shows it pretty well.
Thanks in advance for your support. Should I post what I tried to do with getRotateInstance?
[ October 21, 2008: Message edited by: J.J. Zing ]
[ October 21, 2008: Message edited by: J.J. Zing ]