I would like to determine that pixels are inside a rotated rectangle around the center of the circle.

Let: say I have a circle radius R at the center ( x0, y0 ) Given: theta as the degree of rotation rectangle round the center point and width ( W ) of the rectangle. The image below illustrates the problem

How could I determine which pixel x,y is inside or outside the rectangle?.

Current: What I am doing now is I rotate the points of rectangles and then find inside/outside using those rotated points. I feel it is not efficient.

enter image description here

  • 1
    $\begingroup$ Do you mean entirely inside the rectangle? In the picture there appears to be no pixel entirely inside the rectangle, assuming the grid lines are one pixel apart. Of course, you couldn't actually draw the rectangle, which consists of partial pixels (if I'm right about the grid lines.) Please add some more details to your question. $\endgroup$ – saulspatz Jan 2 at 6:02
  • $\begingroup$ I fixed the picture. may be partly inside or fully inside is fine too. The new picture is better. $\endgroup$ – MooMoo Jan 2 at 6:21
  • $\begingroup$ You want it as function of Theta? $\endgroup$ – Moti Jan 2 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.