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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:49:04+00:00 2026-06-01T15:49:04+00:00

I am having some trouble determining if two line segments are collinear because of

  • 0

I am having some trouble determining if two line segments are collinear because of floating point precision. How can I determine if the line segments are collinear with some tolerance?

  • 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-01T15:49:05+00:00Added an answer on June 1, 2026 at 3:49 pm

    EDITED:

    Line segments are colinear if they contain two of the same points. They are near-colinear if they share one point and are near-parallel.

    Vectors are effectively parallel if the angle between them is less than a threshold you state. Maybe less than .000027 degrees, which is the decimal equivalent of one tenth of a degree-second (which is in latitudinal distance, and equivalently of longitudinal distance at the equator, a difference of approximately ten feet; that’s about the accuracy of civilian GPS).

    You didn’t tell us what language or library you’re using; in .NET’s System.Windows.Media.3D library there is a Vector3D struct which has an AngleBetween() method, making this check a one-liner.

    The “basic” math (it’s actually vector trig, not a “basic” concept by most definitions) is that θ=cos-1( A*B / |A||B| ); that is, the arc-cosine of the quantity of the scalar product of the two vectors divided by the product of their magnitudes.

    The dot product of vector A and vector B, both containing components X, Y, and Z, is XAXB + YAYB + ZAZB. The magnitude of a vector A is sqrt(XA2 + YA2 + ZA2).

    So, in pseudo-C-ish:

    //Vector is a simple immutable class or struct containing integer X, Y and Z components
    public bool CloseEnough(Vector a, Vector b, decimal threshold = 0.000027m)
    {
       int dotProduct = a.X*b.X + a.Y*b.Y + a.Z*b.Z;
       decimal magA = sqrt(a.X*a.X + a.Y*a.Y + a.Z*a.Z); //sub your own sqrt
       decimal magB = sqrt(b.X*b.X + b.Y*b.Y + b.Z*b.Z); //sub your own sqrt
    
       decimal angle = acos(dotProduct/(magA*magB)); //sub your own arc-cosine
    
       if(angle <= threshold
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having some trouble with joining two tables. This is what my two tables
I'm having trouble determining the best way to read some input in for a
having some trouble with hitTestObject and now Flash is telling me it can't convert
I'm having trouble determining from this research paper exactly how I can reproduce the
I'm having some trouble determining what's going on with simplexml_load_string() I'm using the below
having some trouble with this can't understand why it won't work properly. http://host.philmadelphia2.com/~clare/order/ when
Im having some trouble with Jquery Templates and can't seem to figure out what's
Having some trouble overriding ActionBarSherlock styles, hopefully someone can help. I have created a
Having some trouble with what should be a very simple scenario. For example purposes,
Basically having some trouble with using Hover to hide or show an item. 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.