Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line.Segment.intersectionWith can fail #6

Open
fromkeith opened this issue Jun 9, 2012 · 1 comment
Open

Line.Segment.intersectionWith can fail #6

fromkeith opened this issue Jun 9, 2012 · 1 comment

Comments

@fromkeith
Copy link

There is a possibility of Line.Segment.intersectionWith to fail, by trying to access a null object.

Current code:

intersectionWith: function(obj) {
    if (!this.line.intersects(obj)) { return null; }
    var P = this.line.intersectionWith(obj);
    return (this.contains(P) ? P : null);
  }

The problem exists with the value of 'P'. This can be returned as null. Thus when the last line is executed "this.contains(P)" the code will fail, as P is null.

Test Code:

a = Sylvester.Line.Segment.create([600,216], [200, 216])
b = Sylvester.Line.Segment.create([300,616], [200, 216])
a.intersectionWith(b) // returns a valid point
b.intersectionWith(a) // fails! TypeError: Cannot read property 'start' of null
@drpepper
Copy link

I have this problem too, when the line segment ends at the intersection point with another line. Perhaps a floating point error problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants