Solved How to create Pie object?
-
Hello,
I would like to check if the QPoint is inside a pie, which I create using QPainter:
drawPie(int x, int y, int width, int height, int startAngle, int spanAngle)
So I would like something like:
QPie pie(int x, int y, int width, int height, int startAngle, int spanAngle); if(pie.contains(myPoint)) { }
Is a simple way to do that?
-
@TomNow99 well it still holds true, just that you have to 2 additional boundary checks.
I don't have those at hand, from the top of my head. But this stack overflow thread has it:
https://stackoverflow.com/a/51896645 -
@TomNow99 said in How to create Pie object?:
I would like to check if the QPoint is inside a pi
you know, that's basic Pythagoras
(x - centerX) * (x - centerX) + (y - centerY)*(y - centerY) < radius *radius
-
@J-Hilk You are right, but my Pie can be only half / quarter circle, so this is not basic Pythagoras.
Look at the picture:
distance between red Point and the center of the circle is very small, but that point isn't inside pie.
-
@TomNow99 well it still holds true, just that you have to 2 additional boundary checks.
I don't have those at hand, from the top of my head. But this stack overflow thread has it:
https://stackoverflow.com/a/51896645