0

Hello I am making a game in java. I am using a collection of lines to represent a shape to detect collisions. I need to be able to rotate this shape by degrees or radians enter image description here

As you can see from the diagram above the shape is a collection of line segments with 2 points a and b. I need to know how would I rotate all of lines together and still retain the shape.

user2277362
  • 113
  • 1
  • 1
  • 9
  • Just rotate all the points independently, as described in the answer to [your earlier question](http://stackoverflow.com/questions/22491178/how-to-rotate-a-point-around-another-point) – Niklas B. Mar 18 '14 at 23:50

1 Answers1

1

Sounds like a job for AffineTransform (assuming you're doing 2D)

Something to this effect:

Point2D rotatedPoints = new Point2D[yourPoints.length];
AffineTransform at = new AffineTransform();
at.rotate(Math.toRadians(yourDegreeRotation), xToRotateAround, yToRotateAround);
at.transform(yourPoints, 0, rotatedPoints, 0, yourPoints.length);
captainroxors
  • 718
  • 7
  • 18