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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:17:01+00:00 2026-06-07T06:17:01+00:00

Edit: Changed the title. I’m less interested in the two segments being the same,

  • 0

Edit: Changed the title. I’m less interested in the two segments being the same, but rather, if they are colinear with each other, within a certain tolerance. If so, then the lines should be clustered together as a single segment.

Edit: I guess a short way of saying this: I’m trying to cluster similar line segments together in an efficient way.

Say I have line segments f (fx0, fy0) and (fx1, fy1) and g (gx0, gy0) and (gx1, gy1)

These come from something like a computer-vision algorithm edge detector, and in some cases, the two lines are basically the same, but are counted as two distinct lines because of pixel tolerances.

There are several scenarios

  • f and g share the exact same endpoints, eg: f = (0,0), (10,10) g = (0,0), (10,10)
  • f and g share roughly the same endpoints, and roughly the same length, eg : f = (0,0.01), (9.95,10) g = (0,0), (10,10)
  • f is a subset of g, meaning that its endpoints fall within the g segment and share the same slope as the g segment. Think of a roughly drawn line in which the pen has gone back and forth to make it thicker. eg : f = (4.00, 4.02), (9.01, 9.02) g = (0,0), (10,10)

The following would not be considered the same:

  • f and g have a slope difference beyond a certain tolerance
  • f and g may have the same slope but are separated by a distance beyond tolerance, i.e. parallel lines
  • f and g are on the same plane and same slope, but don’t overlap at all…i.e. a set of segments within a dashed line.

The easiest way to tell if they are the same is if gx1 - fx1 <= tolerance (repeat for the three other points), but in some cases, line f may be shorter than line g (again, because of pixel differences and/or poor photo scanning).

So is it better to convert the two segments into polar coordinates and compare the angles? In that case, the two rho’s would be within a tolerance. But then you have to make sure the two line segments have the same “direction”, which is trivial to compute in Cartesian or polar coordinates.

So this is easy to figure out a way, but I’m just wondering if there’s a much cleaner way, based in the linear algebra that I’ve long forgotten?

  • 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-07T06:17:02+00:00Added an answer on June 7, 2026 at 6:17 am

    Your problem is two-fold: you want to compare both the difference in length and difference in angles. To compute the difference in length, you’d take the length of the first line and divide it by the length of the second line.

    To take the difference in angle, you can use atan or, my favourite:

    angle = acos(abs((u dot v)/(u.length * v.length)))

    Hopefully this helps. Sorry for the mistaken answer earlier.

    Old answer:

    Here’s an idea for you: why not compare the difference in the start and end points of the two line segments to the total length of one of the lines? Then your difference function would look something like:

    def difference(Line l1, Line l2):
        # Distance between first point on first line and first point on second line
        first_point_diff = (Line(l1.x1, l2.x1, l1.y1, l2.y1).length())
    
        # Distance between first point on first line and first point on second line
        second_point_diff = (Line(l1.x2, l2.x2, l1.y2, l2.y2).length())
    
        return (first_point_diff + second_point_diff)/l1.length()
    

    This function will return the “difference” between two lines as a fraction of the total length of the first line.

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

Sidebar

Related Questions

EDIT: changed the title. I didn't know it at the time but this is
Edit: Changed title to reflect both methods in post. I'm trying to compare two
Edit: Changed question title from Does C# allow method overloading, PHP style (__call)? -
Edit: My original title has been sort of changed. I suspect the current title
EDIT : Changed title from inheritance to composition. Left body of question unchanged. I'm
EDIT:I've changed the title, because the issue had nothing to do with IE image.load()
EDIT: Changed title to actually be correct I'm trying to simulate a modal popup
EDIT: changed the title to fit the code below. I'm trying to retrieve a
[EDIT: Changed title to better conceptualize the question.] The value of the attribute @xml:space
EDIT: SOLVED. Use any of the solutions below, but document.onload needs to be changed

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.