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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:29:55+00:00 2026-06-05T13:29:55+00:00

How can I tell whether a circle tangents the outer rectangle or is located

  • 0

How can I tell whether a circle tangents the outer rectangle or is located (partially) outside of the rectangle in 2D Euclidean space?

The rectangle will always be aligned with the axes.
Visual representation of a circle-rectangle's border collision

Basically I’m creating a simple game with a ball which moves in certain steps with a certain angle through the space.

  • 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-05T13:29:57+00:00Added an answer on June 5, 2026 at 1:29 pm

    Let’s denote the four sides of the rectangle s1, s2, s3, s4 starting from the top and moving clockwise.

    Check the distance from the circle’s centre to each of the four lines; d1, d2, d3, d4 (numbered corresponding to the sides). Note that there is a simple formula to derive the (orthogonal) distance from a point to a line.

    A necessary (although not sufficient) condition is that the distance from one of the lines is the radius length (pragmatically the difference is less than some delta of your choosing):
    |d1 - r| < delta || ...

    You can make this a sufficient condition if the circle is totally inside the rectangle, which is true iff each distance is less than the distance between the corresponding sides of the rectangle, less the radius:
    d1 <= |s1 - s3|-r && d2 <= |s2 - s4|-r && ...

    Checking partially outside is as simple as checking for the opposite of the last paragraph (and if you require, checking that the radius is still within the box):
    d1 > |s1 - s3|-r || d2 > |s2 - s4|-r || ...

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

Sidebar

Related Questions

How can I tell whether a circle and a rectangle intersect in 2D Euclidean
How can I tell whether two triangles intersect in 2D Euclidean space? (i.e. classic
Is there a way I can tell whether stderr is outputting to a file
How can I tell whether an algorithm is stable or not?.. Also, how does
How can you tell whether the device is oriented vertically (portrait) or horizontally (landscape)?
Can anyone tell me whether Helvetica is a browser base font? If so, it
Can someone tell me whether MSMQ (using transactions) supports competing consumers? Basically, I have
Can someone tell me whether an open source project with GPL 2.0 license hosted
I think I read something about a function appengine has that can tell whether
How can I tell whether a remote message queue exists ? The documentation states

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.