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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:11:17+00:00 2026-05-25T15:11:17+00:00

Given is a Cartesian coordiante system, a from-position A (X/Y), and a to-position B

  • 0

Given is a Cartesian coordiante system, a from-position A (X/Y), and a to-position B (X/Y). I want to move from A to B. However, I can only move on the eight directions N, NE, E, SE, S, SW, W, NW.

I know that I can calculate the “best” of these directions to take from the current position A via the dot product with the unit vectors of the axis (the eight directions), where the biggest dot product is the direction to take. But this approach leads to some kind of “oscillation” between two directions, if A is exactly in between these two.

So I am searching for an algorithm now that sovles this problem of getting from A to B with only one or max. two directions to use. Of course I am ignoring any obstalces now, so that theoretically I can always get from A to B with a maximum of two different directions. I could probably solve this problem with a bunch of if-statements, but I would prefer a more elegant solution…

I hope that was somewhat understandable 🙂

Thanks in advance for any ideas!

Kind regards, Matthias

  • 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-25T15:11:17+00:00Added an answer on May 25, 2026 at 3:11 pm

    the simplest solution is to head in a “diagonal” direction until you are on the same row/column as the target, and then to use the horizontal/vertical direction.

    in other words:

    • check if you are horizontally / vertically aligned. if so, move in that direction and finish.
    • otherwise, find the closest diagonal direction using the method you have.
    • move along the diagonal until you are horizontally or vertically aligned. then move in that direction and finish.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given long long int x, y; , I want a function that can compare
I want to convert some point coordinates which are given in a cartesian system
Given two lists, I can produce a list of all permutations the Cartesian Product
Suppose I am given number of lines segments in Cartesian coordinate system.Each line is
How can I get the Cartesian product (every possible combination of values) from a
given is a Cartesian coordinate system and a point(x,y) within this system. For example
This question asks how to compute the Cartesian product of a given number of
Given an absolute or relative path (in a Unix-like system), I would like to
Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using
Given 2 arrays Array1 = {a,b,c...n} and Array2 = {10,20,15....x} how can I generate

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.