   Point in rotated rectangle - axis-aligned method and wrong rectangle identified
  Hi,I'm writing a game with multiple (let's say 10) rotated rectangles on the screen which I need to iterate through upon the game area click to check which one has been clicked.Ok, the standard method in this case:1. get the click coordinates2. start iterating though rotated rectangles collection2a. perform click coordinates rotation by negative rotated rectangle rotation angle to get the axis-aligned rectangles2b. check whether the rotated click lies within rectangle boundariesNow, that works fine, but has some minor flaw: while iterating through those rectangles and performing click point rotation by currently analyzed rectangle's angle it may happen that the the rotated point will match another rectangle!I came up with a solution to check only rectangles within the radius of max(rectangle_dimension) but I don't think that's right attitude, because still the issue may occur in case of 2 perpendicular rectangles.What is the other possible solutions to that?Cheers,teel   
  Perhaps I don't understand the situation. Assuming that the rectangles do not overlap, something likeQuote:Original post by teelit may happen that the the rotated point will match another rectangleisn't be possible. Tempted due to the wording chosen in the OP, I ask whether you only consider rotation or also translation? I.e. you have to transform the click point with the inverse of the entire placement. Let's assume you rotate a rectangle and translate it then to its final location. Hence you need to inverse translate the click point and inverse rotate it then. Now you can do the test.;Quote:Original post by haegarrPerhaps I don't understand the situation. Assuming that the rectangles do not overlap, something likeQuote:Original post by teelit may happen that the the rotated point will match another rectangleisn't be possible.Yeah, thanks, that was just a fault in my calculation procedure...Regards,Tomek