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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:51:48+00:00 2026-05-27T18:51:48+00:00

I have some point on a 2D grid (x, y) and I need to

  • 0

I have some point on a 2D grid (x, y) and I need to find all points that are n distance away from that point. The way I’m measuring distance is by using the distance formula between the two points. Anyone know how to do this?

Edit: Just for reference, what I’m trying to do is to write some AI path finding that will maintain some distance away from a target in a system that uses grid based locations. Currently I’m using A* path finding, but I’m not sure if that matters or makes a difference since I’m kind of new to this stuff.

  • 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-05-27T18:51:49+00:00Added an answer on May 27, 2026 at 6:51 pm

    Here’s what I would do:

    1. First filter out all points that are further than D on either x or y. These are certainly outside the circle of radius D. This is a much simpler computation, and it can quickly eliminate a lot of work. This is a outer bounding-box optimization.

    2. You can also use an inner bounding-box optimization. If the points are closer than D * sqrt(2)/2 on either x or y, then they’re certainly within the circle of radius D. This is also cheaper than calculating the distance formula.

    3. Then you have a smaller number of candidate points that may be within the circle of radius D. For these, use the distance formula. Remember that if D = sqrt(Δx2+Δy2), then D2 = Δx2+Δy2.
      So you can skip the cost of calculating square root.


    So in pseudocode, you could do the following:

    for each point
    begin
        if test 1 indicates the point is outside the outer bounding box, 
        then skip this point
    
        if test 2 indicates the point is inside the inner bounding box, 
        then keep this point
    
        if test 3 indicates the point is inside the radius of the circle, 
        then keep this point
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At some point I must have moved files from one location to another using
I have several objects in my app that can become nil at some point
I have a Sitecore/ASP.NET projects that I'm developing. Today at some point I inadvertently
I need to visualize some data. It's basic 2D grid, where each cell have
I have a huge application and at some point, when a redirect is involved
In my application at some point, I have to call the Propel library version
I must have pressed on the wrong button at some point, and now when
We have a memory overwrite problem. At some point, during the course of our
I have an application designed for iPhone OS 2.x. At some point I have
I have a class which works with social networks related stuff. At some point

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.