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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:39:35+00:00 2026-05-20T15:39:35+00:00

I’m searching the way to efficiently find the point on an edge which is

  • 0

I’m searching the way to efficiently find the point on an edge which is the closest point to some other point.

Let’s say I know two points which are vertices of the edge. I can calculate the equation of the line that crosses those points.

What is the best way to calculate the point on the edge which is the closest point to some other point in the plane.

I would post an image but I don’t have enough reputation points.

  • 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-20T15:39:35+00:00Added an answer on May 20, 2026 at 3:39 pm

    You have three zones to consider. The “perpendicular” approach is for the zone in the middle:

    enter image description here

    For the other two zones the distance is the distance to the nearest segment endpoint.

    The equation for the segment is:

    y[x] = m x + b
    

    Where

      m -> -((Ay - By)/(-Ax + By)), 
      b -> -((-Ax By + Ay By)/(Ax - By))  
    

    And the perpendiculars have slope -1/m

    The equations for the perpendicular passing thru A is:

      y[x] = (-Ax + By)/(Ay - By) x + (Ax^2 + Ay^2 - Ax By - Ay By)/(Ay - By)
    

    And the perpendicular passing thru B is the same exchanging the A’s and B’s in the equation above.

    So you can know in which region lies your point introducing its x coordinate in the above equations and then comparing the y coordinate of the point with the result of y[x]

    Edit

    How to find in which region lies your point?

    Let’s suppose Ax ≤ Bx (if it’s the other way, just change the point labels in the following formulae)

    We will call your point {x0,y0}

    1) Calculate

     f[x0] =  (-Ax + By)/(Ay - By) x0 + (Ax^2 + Ay^2 - Ax By - Ay By)/(Ay - By)
    

    and compare with y0.

    If y0 > f[x0], then your point lies in the green field in the figure above and the nearest point is A.

    2) Else, Calculate

    g[x0] =  (-Bx + Ay)/(By - Ay) x0 + (Bx^2 + By^2 - Bx Ay - By Ay)/(By - Ay)  
    

    and compare with y0.

    If y0 < g[x0], then your point lies in the yellow field in the figure above and the nearest point is B.

    3) Else, you are in the “perpendicular light blue zone”, and any of the other answer tell you how to calculate the nearest point and distance (I am not going to plagiarize :))

    HTH!

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

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I know there's a lot of other questions out there that deal with this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Seemingly simple, but I cannot find anything relevant on the web. What is the
I would like to run a str_replace or preg_replace which looks for certain words

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.