Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8302665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:20:35+00:00 2026-06-08T17:20:35+00:00

SOLVED: See my answer . I’m trying to find a point that is interior

  • 0

SOLVED: See my answer.

I’m trying to find a point that is interior to an arc so when a floodfill occurs it does not accidentally fill an area outside the arc. As long as the absolute value of the distance between the two angles: start and end; are less than PI this works (There are a couple extreme edge cases where the drawn lines are so close that the point picked is part of those lines, but that’s for a different day…).

The problem I’m having is when the absolute value of the distance between the start and end angles is greater than PI the flood occurs on the exterior of the arc instead of the interior. One example of many is: if the arc starts at 0 and ends at 3PI/2 the absolute value of the distance is 3PI/2, the flood occurs between the angles as if the absolute value distance were PI/2 and floods the entire screen except the pac-man-shaped arc.

EDIT:

To avoid confusion, here is the definition of an arc according to allegro (and trigonometry in general):

void arc(BITMAP *bmp, int x, y, fixed ang1, ang2, int r, int color);

Draws a circular arc [minus the initial/terminal sides or center point] with centre [sic] x, y and radius r, in an
anticlockwise [sic] direction starting from the angle a1 and ending when it
reaches a2….Zero is to the right of the centre [sic] point, and larger
values rotate anticlockwise [sic] from there.

Square brackets are my notation.

I’ve already taken care of converting from allegro’s (stupid) use of fixed integers to the proper radian values.

END EDIT

void Arc::Draw(BITMAP* dest, int color, bool filled, bool showCenter, bool showSides) {

    if(showSides || filled) {
        Line initial(GetX(), GetY(), GetZ(), GetStartPoint().GetX(), GetStartPoint().GetY(), GetZ(), false);
        initial.SetColor(color);

        Line terminal(GetX(), GetY(), GetZ(), GetEndPoint().GetX(), GetEndPoint().GetY(), GetZ(), false);
        terminal.SetColor(color);

        initial.Draw(dest, initial.GetColor(), false);
        terminal.Draw(dest, terminal.GetColor(), false);

    } else if(showCenter) {
        putpixel(dest, GetX(), GetY(), color);
    }

    //Draw arc first to prevent flood overflow.
    arc(dest, GetX(), GetY(), AngleConverter::RadianToFixed(_startAngle), AngleConverter::RadianToFixed(_endAngle), _radius, color);

    if(filled) {

        double distance = std::fabs(this->_endAngle - this->_startAngle);
        if(distance < a2de::A2DE_PI) {

            Line displace(GetStartPoint(), GetEndPoint(), false);
            Point displacePoint(displace.GetCenter());
            floodfill(dest, displacePoint.GetX(), displacePoint.GetY(), color);

        } else if(distance > a2de::A2DE_PI) {

            Line displace(GetStartPoint(), GetEndPoint(), false);
            Vector2D center_of_displacement(displace.GetCenter());
            Vector2D center_point(this->_center);
            Vector2D direction_of_center(center_of_displacement - center_point);

            double angle = std::atan2(direction_of_center.GetY(), direction_of_center.GetX());
            Vector2D flood_point = center_point - direction_of_center;
            flood_point += angle;

            double x = flood_point.GetX() > 0.0 ? std::ceilf(flood_point.GetX()) : std::floorf(flood_point.GetX());
            double y = flood_point.GetY() > 0.0 ? std::ceilf(flood_point.GetY()) : std::floorf(flood_point.GetY());
            floodfill(dest, x, y, color);

        } else {

            if(_startAngle == 0.0 || _endAngle == a2de::A2DE_2PI) {
                floodfill(dest, GetX(), GetY() - 1, color);
            } else if(_endAngle == 0.0 || _startAngle == a2de::A2DE_PI) {
                floodfill(dest, GetX(), GetY() + 1, color);
            }

        }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:20:36+00:00Added an answer on June 8, 2026 at 5:20 pm

    SOLVED:

    1) Calculate Center of Arc:

    double e = GetEndAngle();
    double s = GetStartAngle();
    double d = e - s;
    
    double arc_center_x = 0.0;
    double arc_center_y = 0.0;
    double offset = 0.0;
    if(d < 0.0) {
        offset = PI;
    }
    arc_center_x = (GetPosition().GetX() + std::cos(((s + e) / 2.0) + offset) * GetRadius());
    arc_center_y = (GetPosition().GetY() + -std::sin(((s + e) / 2.0) + offset) * GetRadius());
    _center = Vector2D(x, y);
    

    2) Calculate Line from that center to the position of the sector:

    Line l(arc_center_x, arc_center_y, p_x, p_y);
    

    3) Get the mid-point of that line which is always interior to the angles of the sector:

    double x = l.GetCenter().GetX();
    double y = l.GetCenter().GetY();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[SOLVED] See my answer below. I am trying to use stringstream (named ss) to
UPDATE: SOLVED!!! Please see the answer I added below Does anyone know if there
EDIT 2 : I have solved the problem (see answer below) Please note that
SOLVED: See my answer below I'm experiencing the same issue that Austin Hyde experienced
[EDIT: Problem solved. Please see my answer below.] In my app I call the
(Problem solved now, see answers below) Hello, in my app I am trying to
Problem Solved - See bottom for solution notes I'm trying to build a simple
This is something that I solved using reflection, but would like to see how
SOLVED See my answer below. Question left unchanged for anyone else who has trouble
SOLVED! See my self-answer below. I'm building two Metro-style apps using Javascript and HTML,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.