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

  • Home
  • SEARCH
  • 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 8907615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:57:46+00:00 2026-06-15T02:57:46+00:00

I have a piece of code that checks if the given 3 coordinates are

  • 0

I have a piece of code that checks if the given 3 coordinates are linear to one another (if so, return true). But is there a way to make the code give or take a few pixels/plots?

private boolean collinear(double x1, double y1, double x2, double y2, double x3, double y3) {
    return (y1 - y2) * (x1 - x3) == (y1 - y3) * (x1 - x2);
}

You see, the coordinates have to be exactly inline for it to register as linear. How will I be able to make it look within a ‘range’ of some kind, for it to check within a value, and then to then set the coordinates with the new value?

—- Added —-

I’m trying to see if the 3 points make a linear line, but I want it to check within a threshold (as some points maybe off by a little). Once the Java has found that in fact the points are linear (give or take), I want it to then replace the x1, x2, x3, y1 ect … with what the value would have been that Java checked against.

  • 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-15T02:57:49+00:00Added an answer on June 15, 2026 at 2:57 am

    Using the Hesse Normal Form you can calculate the perpendicular distance from a point to a line. So when the distance is smaller than a treshhold, they are sufficiently near.

    Such code is called distanceFromLine()
    Java has that built in

       Line2D line = new Line2D.Double(x0, y0, x1, y1);
    
        double distance = line.ptLineDist(px, py);
    
        if (Math.abs(distance) < threshold) {
                  // is Near line
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code that basically checks if one or more files
I have created a piece of code that checks files for a user-submitted string
I have this little piece of code that just checks for a particular text
I have a piece of code that checks to see if a macro is
I have a small piece of code that checks a string for a url
I have a piece of code that, when the page loads, checks through a
I have the following piece of code that checks whether port 443 is open
I have a piece of code in c# that checks, if a value is
I have a piece of code that checks a time and then adds hours
I have a piece of code that checks that a survey response picked by

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.