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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:16:40+00:00 2026-06-13T08:16:40+00:00

I am coming up or am looking for an equation to this trivial problem:

  • 0

I am coming up or am looking for an equation to this trivial problem:

Well it’s more about knowing the direction in which the user is going based on the users geo location.

As you can see below the User’s first coordinates are in point x after a minute or two the user’s coordinates changed and is now at point y

Given the User’s coordinates x and y , the Intersection point A and Point B
how do I come up with a formula that would tell me if the user is in the right lane (going from point B to point A)
or is in the left lane (going from point A to point B).

see image

  • 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-13T08:16:41+00:00Added an answer on June 13, 2026 at 8:16 am

    Assuming this is just coordinate based, and does NOT need to take into consideration the road or path the points are on, use the dot product. Create segments from points and dot product of two segments is positive if segments are aligned (point is same direction with less than 90 degrees) and negative if segments point in opposite directions.

    If problem needs to consider the road or path, then the below will not work, because road/path may at times curve back and be moving away from destination, so correct direction on the road/path would temporarily be increasing distance to destination (as the crow flies). As your question is worded it SOUNDS like you want to be able to tell, from a single user position X and Y values which lane of a defined road they are in. If you think about it, that is simply not possible without knowing the exact geometry of the road/path itself. If it is curved at all, it becomes impossible to determine. Think about it. For ANY given position on the ground, you could bend the road one way or the other to cause that spot to be in either lane…

    But with TWO positions, that represent movement in time, and the assumption that they are moving forward in whatever lane they are in, you CAN determine whether that motion is more towards Point A or towards Point B.

    Technically, dot product of two vectors A and B
    A dot B = |A| x |B| x Cos(Angle between them))

    So, and AGAIN, this is assuming you don’t need to take into consideration the shape or curvature of the road, you just make two directed segments, one from B to A, and another from one user position to a subsequent user position (representing his/her motion during some finite time interval), and take the dot product of these two segments. If it’s positive, he’s moving towards A, if negative, hes moving towards B.

    (this code is simplified)

    public struct Point
    {
        public double X { get; set; }
        public double Y { get; set; }
    
        private Point(double xValue, double yValue)
        { X = xValue; Y = yValue; }
        public static Point Make(double x, double y)
        { return new Point(x, y); }
    }
    
    
    public class Segment
    {
        public Point StartPoint { get; set; }
        public Point EndPoint { get; set; }
    
        #region ctor / factories
        protected Segment(Point startPoint, Point endPoint)
            : base(startPoint, (endPoint.Y - startPoint.Y) /
                                (endPoint.X - startPoint.X))
        {
           StartPoint = startPoint;
           EndPoint = endPoint;
        }
        public static new Segment Make(Point startPoint, Point endPoint)
        {
            if (startPoint == endPoint)
                throw new Exception(
                    "You must use two different points to define a segment.");
            return new Segment(startPoint, endPoint);
        }
        public static new Segment Make(double ax, double ay, double px, double py)
        { return Make(Point.Make(ax, ay), Point.Make(px, py)); }
    
        public static Segment NullSegment { get { return new Segment(); } }
        #endregion ctor / factories
    
        public double Length
        {
            get
            {
                return Math.Sqrt(
                    Math.Pow(EndPoint.Y - StartPoint.Y, 2) +
                    Math.Pow(EndPoint.X - StartPoint.X, 2));
            }
        }
    
        public double DotProduct(Segment seg, bool normalize = false)
        {
            double
                dAx = EndPoint.X - StartPoint.X,
                dAy = EndPoint.Y - StartPoint.Y,
                dBx = seg.EndPoint.X - seg.StartPoint.X,
                dBy = seg.EndPoint.Y - seg.StartPoint.Y;
    
            var dP = dAx * dBx + dAy * dBy;
    
            return normalize? dP / Length / seg.Length : dP;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coming from MySQL and not knowing about ROLEs I absentmindedly tried this GRANT CREATE
As coming from python I'm looking for something equivalent to this python code (
I'm looking for ways to detect/estimate the country from which a http-request is coming
I am looking more heavily HTML 5 now, but I keep coming back to
Coming from C#... I was looking at this website http://www.harding.edu/fmccown/vbnet_csharp_comparison.html And noticed that it
So coming off of this question: Which is fast comparison: Convert.ToInt32(stringValue)==intValue or stringValue==intValue.ToString() I
I'm looking for a Java profiler that works well with the JVM coming with
I've got a problem that keeps coming up with normalized databases and was looking
I am looking to use Adobe Air to visualize information coming from the Serial
I'm coming to Postgres from Oracle and looking for a way to find the

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.