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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:51:25+00:00 2026-05-24T00:51:25+00:00

I have to get the (shortest)/(an optimal) distance between two points in 2D. I

  • 0

I have to get the (shortest)/(an optimal) distance between two points in 2D. I have to avoid shapes that are lines, that may be connected together. Any suggestion on how to represent the nodes I can travel on? I have thought of making a grid, but this doesn’t sound very accurate or elegant. I would consider a node as unwalkable if any point of a line is inside a square (with the node being the center of the square).

enter image description here

An example would be going from point A to B.

Is the grid the recommended way to solve this? Thanks A LOT in advance!

  • 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-24T00:51:27+00:00Added an answer on May 24, 2026 at 12:51 am

    I think this is essentially Larsmans’ answer made a bit more algorithmic:

    Nodes of the graph are the obstacle vertices. Each internal vertex actually represents two nodes: the concave and the convex side.

    1. Push the start node onto the priority queue with a Euclidean heuristic distance.
    2. Pop the top node from the priority queue.
    3. Do a line intersection test from the node to the goal(possibly using ray-tracing data-structure techniques for speedup). If it fails,
    4. Consider a ray from the current node to every other vertex. If there are no intersections between the current node the vertex under consideration, and the vertex is convex from the perspective of the current node, add the vertex to the priority queue, sorted using the accumulated distance in the current node plus the distance from the current node to the vertex plus the heuristic distance.
    5. Return to 2.

    You have to do extra pre-processing work if there are things like ‘T’ junctions in the obstacles and I wouldn’t be surprised to discover that it breaks in a number of cases. You might be able to make things faster by only considering the vertices of the connected component that lies between the current node and the goal.

    So in your example, after first attempting A,B, you’d push A,8, A,5, A,1, A,11, and A,2. The first nodes of consideration would be A,8, A,1, and A,5, but they can’t get out and the nodes they can reach are already pushed on the queue with shorter accumulated distance. A,2 and A,11 will be considered and things will go from there.

    Modified image.

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

Sidebar

Related Questions

I have an application that finds the shortest path between 2 squares, and when
I need to find the shortest route between multipe points. Let's say that I
I am trying to calculate the shortest distance between any two numbers in an
So I have a class that has the following member variables. I have get
I am writing a program to calculate the shortest path between two nodes. In
I have a URL that is being generated using GET variables from a form
I have a time line of 500 points. On a timeline that wraps around
Suppose I was given a URL. It might already have GET parameters (e.g. http://example.com/search?q=question
<div id=container1> <span>...</span> </div> <div id=container2> <span>...</span> </div> Say if I have get the
I have to get the sub total of time spent in SQL any ideas?

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.