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 95767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:42:35+00:00 2026-05-10T23:42:35+00:00

How can I tell whether a circle and a rectangle intersect in 2D Euclidean

  • 0

How can I tell whether a circle and a rectangle intersect in 2D Euclidean space? (i.e. classic 2D geometry)

  • 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. 2026-05-10T23:42:36+00:00Added an answer on May 10, 2026 at 11:42 pm

    There are only two cases when the circle intersects with the rectangle:

    • Either the circle’s centre lies inside the rectangle, or
    • One of the edges of the rectangle has a point in the circle.

    Note that this does not require the rectangle to be axis-parallel.

    Some different ways a circle and rectangle may intersect

    (One way to see this: if none of the edges has a point in the circle (if all the edges are completely ‘outside’ the circle), then the only way the circle can still intersect the polygon is if it lies completely inside the polygon.)

    With that insight, something like the following will work, where the circle has centre P and radius R, and the rectangle has vertices A, B, C, D in that order (not complete code):

    def intersect(Circle(P, R), Rectangle(A, B, C, D)):     S = Circle(P, R)     return (pointInRectangle(P, Rectangle(A, B, C, D)) or             intersectCircle(S, (A, B)) or             intersectCircle(S, (B, C)) or             intersectCircle(S, (C, D)) or             intersectCircle(S, (D, A))) 

    If you’re writing any geometry you probably have the above functions in your library already. Otherwise, pointInRectangle() can be implemented in several ways; any of the general point in polygon methods will work, but for a rectangle you can just check whether this works:

    0 ≤ AP·AB ≤ AB·AB and 0 ≤ AP·AD ≤ AD·AD 

    And intersectCircle() is easy to implement too: one way would be to check if the foot of the perpendicular from P to the line is close enough and between the endpoints, and check the endpoints otherwise.

    The cool thing is that the same idea works not just for rectangles but for the intersection of a circle with any simple polygon — doesn’t even have to be convex!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer In LiveCycle Administration Console simply go to Home > Services… May 11, 2026 at 9:44 am
  • added an answer I use the following folder structure for all my solutions… May 11, 2026 at 9:44 am
  • added an answer Personally, I'd rather compartmentalize those things. For example, why do… May 11, 2026 at 9:44 am

Related Questions

How can I tell whether a circle and a rectangle intersect in 2D Euclidean
How can I tell from the assembly name, or assembly class (or others like
How can I tell in JavaScript what path separator is used in the OS
How can I tell if SP1 has been installed on VS2008? e.g. If I'm
How can I tell if an App is ASP.NET 2.0 or ASP.NET 1.1. This
How can I tell when Windows is changing a monitors power state?
How can I tell if a method is running in the context of an
How can I tell unix find to include in it's recursive search a folder
Problem: How can I tell if a selection of text in the CRichEditCtrl has
In Specman, how can I tell if a reference to a unit has the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.