question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lineIntersectsLine is not commutative

See original GitHub issue

Hi,

I noticed this:

const line1 = [
  [50.054358, 8.693184],
  [50.055604, 8.685873]
];
const line2 = [
  [50.054228, 8.69338],
  [50.054358, 8.693184]
];
lineIntersectsLine(line1, line2);
// false
lineIntersectsLine(line2, line1);
// true

Note that the start of line1 and the end of line2 are identical.

What do you think is the expected result? Since the lines share a point, they arguably do intersect. However my use case is around multiple lines fanning out from a single point and I don’t want to count those as intersecting.

I’d suggest adding a parameter excludeEndpoints that determines wether sharing a start/end-point should count as intersecting. What do you think?

I can probably open a PR if we decide on something.

Kind regards, yeldiRium

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
HarryStevenscommented, Jul 16, 2021

Thanks @yannbriancon. I’ve merged your PR.

0reactions
yannbrianconcommented, Jul 19, 2021

@HarryStevens Thanks for this great library!

I am though having issues with the fact that if the end point of one line is on the other line but is not its beginning or end, the lines are not detected as intersecting.

Here is an example: line1 = [a, b] = [[0, 0], [1, 0]] line2 = [c, d] = [[0.5, -1], [0.5, 0]]

a---d---b
    |
    |
    c
lineIntersectsLine([[0, 0], [1, 0]], [[0.5, -1], [0.5, 0]]) // returns false

Here is a PR fixing the issue https://github.com/HarryStevens/geometric/pull/23 but reach out if you have another fix in mind

Read more comments on GitHub >

github_iconTop Results From Across the Web

intuition for matrix multiplication not being commutative
I like to simply not have intuition on this, and take for granted that in general, composition of functions will not be commutative...
Read more >
GABLE: A Matlab Tutorial for Geometric Algebra
This tutorial is not a tutorial on Matlab, and to work more easily with it ... The sign-change in the exponent is due...
Read more >
A Book of Abstract Algebra - UMD Math
is not commutative. EXERCISES. A. Examples of Abelian Groups. Prove that each of the following sets, with the indicated operation, is an abelian...
Read more >
GRADE 5 • MODULE 6
They not only reach back to recall learning from the very beginning of Grade 5, ... T: Line intersects line . ... commutative...
Read more >
Multiplication of Matrices is Not Commutative - YouTube
Register for FREE at http://deltastep.com or download our mobile app: https://bit.ly/3akrBoz to get all learning resources as per ICSE, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found