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
Intersection method of a Line. #2930
Conversation
The test that identified this should be added to the test suite. |
@smichr There is no test for this currently, I found the drawback while looking at the code(For rays it checked the xdirection whereas we have to check both x and y directions respectively).I will add some tests in the test suite. |
Does the following work? (I suspect that the 2nd test regarding source is not sufficiently general.)
|
@smichr It is enough because it is not the full code because it just checks for the cases when the rays are similar or when they are parallel. a1, b1, c1 = self.coefficients |
I think the lines are parallel in every case; you can assert that with |
@smichr I think there is a bit of misunderstanding, I already modified the code and it works for the above cases you mentioned. |
It seems like you are assuming it work. Please post your results. I get
|
@smichr Use [Segment(z, p)] because in the code it returns like that.Same for the Ray too. |
Note: the code I gave had some errors itself. The following highlights the problem:
The raw code is
|
@smichr Have a look now, It's working. |
It might be helpful to draw a picture
That should be [Ray((0,0),(1,1))]. Perhaps you want to see if o.contains(self.source) then return self else return o? |
btw, stating it the way I did will guarantee that self is returned in the case that both share the same source |
@smichr Sorry I got a little confused,But I think this does the job? |
return [o] | ||
return [self] | ||
return [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should raise an error in this case -- we already know that the rays are coincident. In fact, I would be surprised if this ever got triggered. I think return [self] if (self.source in o) else [o]
is fine. Did you find otherwise?
@smichr I have made the changes. |
I opened modifications at #2940 -- can you take a look |
Gives wrong result in the following case.
a = Ray(Point(0,0),Point(0,4))
b = Ray(Point(0,1),Point(0,-1))
a.intersection(b)
Ray(Point(0,0),Point(0,4))
But the result should be
Segment(Point(0,0),Point(0,1))