I want to draw circle segment, segment will be drawn dependent on mouse position, in this image you can see what I want to achieve:
https://imgur.com/a/HKiHcas you can see, circle segment is looking to mouse, I had been trying to do it alone, but I can't.
This was my idea:
my basic circle draw code:
gameWindow.clear(sf::Color{ 60, 60, 60 });
float angle = PI;
float radius = 50;
unsigned points = 50;
VertexArray circle(LinesStrip, 0);
Vector2f orgin = gameWindow.getView().getCenter();
do
{
Vector2f pointPos = { cos(angle) * radius, sin(angle) * radius };
pointPos += orgin;
circle.append(pointPos);
angle -= PI * 2 / points;
} while (angle > -PI);
circle.append(circle[0]);
gameWindow.draw(circle);
gameWindow.display();
getting angles:
alpha = atan2(mouse.y, mouse.x);
beta = alpha - alpha / 2;
gamma = alpha + alpha / 2;
as you can see I set range from PI to -PI, to have the same angle range as in atan2.
Next I wanted to check points that are in range specified by beta and gamma, and that worked, but partionally...
Because in some cases, my circle was drawed in that way:
https://imgur.com/a/N5e3bInverting beta and gamma not worked to me, I created conditions that were checking that beta and gamma are in range <-PI; PI>, if not, then I changed for example angles, but that not worked too.
After hour of thinking, and complicating my code, I removed it, and I think that I need help.
Please show me how can I draw circle segment in that way.
Thanks.