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

  • Home
  • SEARCH
  • 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 8793343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:06:38+00:00 2026-06-13T23:06:38+00:00

I have a list with ellipse objects with the parameters (Point Begin, Point End,

  • 0

I have a list with ellipse objects with the parameters (Point Begin, Point End, Color c). Now I want to ensure when I click somewhere if I did hit an ellipse.

I also do this with rectangles which already works and looks something like this:

 case 3: // Rectanglefill
        return p.X >= Begin.X && p.X <= End.X && p.Y >= Begin.Y && p.Y <= End.Y;

In this method I only want to return the bool True if I have a hit and False if the mouse click didn’t hit something.

Now for the ellipse I already have this:

case 4: // Ellipsfill
/*  int radiusx = Math.Abs(End.X - Begin.X) / 2;
    int radiusy = Math.Abs(End.Y - Begin.Y) / 2;
    int midpointx = (Begin.X + End.X) / 2;
    int midpointy = (Begin.Y + End.Y) / 2;

return ((Math.Pow((p.X -midpointx) / radiusx, 2) + Math.Pow((p.Y - midpointy) / radiusy, 2)) > 1);

But this doesn’t work.

  • 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-13T23:06:39+00:00Added an answer on June 13, 2026 at 11:06 pm

    Your equation is Ok, you just have to put <1 (or <=1 if you want to include the points on the ellipse) instead of >1

    case 4: // Ellipsfill
        double radiusx = Math.Abs((double)End.X - (double)Begin.X) / 2.0;
        double radiusy = Math.Abs((double)End.Y - (double)Begin.Y) / 2.0;
        double midpointx = ((double)Begin.X + (double)End.X) / 2.0;
        double midpointy = ((double)Begin.Y + (double)End.Y) / 2.0;
    
    return ((Math.Pow((p.X -midpointx) / radiusx, 2) + Math.Pow((p.Y - midpointy) / radiusy, 2)) < 1.0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written my own java.util.List implementation, and now i want to store it
I have list of articles on the page in table and i want to
I have list of structure. I want to modify a particular data from the
I have List I want to sort Desc by Priority, which is int and
i have list of rows that user select and i want to delete them,
I have a list of objects I need to sort according to properties of
I have sticky point with a list. After some work I could generate my
i have a list of objects: static List table_rows = new ArrayList(); Which i
I have list of input area in the form with id like contact1_title, contact2_title,
I have list of textareas. For textareas I use tinyMCE Editor. When I start

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.