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

The Archive Base Latest Questions

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

Possible Duplicate: How can I tell if a point is nearby a certain line?

  • 0

Possible Duplicate:
How can I tell if a point is nearby a certain line?

//Returns the point on the line traced from start to end which
//comes nearest to 500,000, 500,000. The points are scaled between
//1,000,000 and 0 from their original fp types.
Point closestToCentre(Point start, Point end);

Anyone know of quicker way than single stepping through the pixels?

Could some one more alert than me demonstrate their maths & geometry prowess please?

_______EDIT___________

Thanks Kris, this was confusing me :

[x; -a/bx-c/b]=[0; -c/b]-1/b[-b; a]x.

Now I see it is just splitting (mainly the y component) the vector into two which combine to yield the same result. Got the old partial fractions brain cell excited for a minute then 🙂

_______EDIT_________

Jason Moore, thanks for the inspiration, here is what I am doing, graphically,

64x64 square with 2 sample lines each passing edge to edge and missing the centre by some distance

I hope that is clearer.

____EDIT________

So I could reasonably expect to take a line at right angles to my sampled line and run it from the centre but how to tell when they touch?

enter image description here

I think Kris’s page of equations is the way to go. If you’re all telling me it is a two step process. It is just two simultaneous equations now, so I may not need Kris’s derivations.

____EDIT_________

Whether good or bad thing, I don’t know, but the beauty of stackoverflow as a search engine has revealed to me several routes of investigation. Chiefly I like the first solution here:
Shortest distance between a point and a line segment.

But to prove this to my self I needed the link from matti’s solution at the bottom (but one):

http://www.topcoder.com/tc?d1=tutorials&d2=geometry1&module=Static

The derivation is so simple and elegant even I could follow it!

Given http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html

  • 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-25T00:28:40+00:00Added an answer on May 25, 2026 at 12:28 am

    This is a matter of linear projection of a point onto a line, which can be done with some fine vector gymnastics, as elaborated at MathWorld.

    The article details how to find the shortest distance from a point to a line, and one of the intermediate steps is finding the perpendicular line from the point x,y to the original line. Intersecting these two lines will give you the point, on the line, closest to x,y.

    Edit in response to comment: What equation (2) in the link is doing is transforming the vector into a form reminiscent of y = mx + c, which allows you to quickly and easily read off the gradient, from which the perpendicular gradient can be easily calculated.

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

Sidebar

Related Questions

Possible Duplicate: Can I run from command line program created by Eclipse? I am
Possible Duplicate: Where can I learn web programming from start to mastery? I want
Possible Duplicate: How to tell if a list is infinite? In Haskell, you can
Possible Duplicate: Can a Bash script tell what directory it's stored in? Is there
Possible Duplicate: Special (magic) methods in Python who can tell me what can call
Possible Duplicate: How can I tell whether an element matches a selector? I've been
Possible Duplicate: How can you programmatically tell an HTML SELECT to drop down (for
Possible Duplicate: Problem installing my Android apps Any body can tell me how can
Possible Duplicate: SharedPreferences file Can you please tell me where does sharePreference of an
Possible Duplicate: Property vs. instance variable Can someone tell me what is the difference

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.