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

Intersection of line and cylinder #44

Closed
pauljurczak opened this issue Sep 25, 2021 · 5 comments
Closed

Intersection of line and cylinder #44

pauljurczak opened this issue Sep 25, 2021 · 5 comments

Comments

@pauljurczak
Copy link
Contributor

Is intersection of line and cylinder implemented? I tried this:

c = Cylinder()
l = Line(Point(2, 2, 2), Point(3, 3, 3))
print(l.meet(c))

without success.

@jan-mue
Copy link
Owner

jan-mue commented Sep 26, 2021

It is implemented but you have to use the intersect method of the Quadric/Cylinder class which returns a list of points instead of the single point/subspace that meet returns. This code should work:

c = Cylinder()
l = Line(Point(2, 2, 2), Point(3, 3, 3))
print(c.intersect(l))

I'll close this issue but please let me know if you have any more questions.

@jan-mue jan-mue closed this as completed Sep 26, 2021
@pauljurczak
Copy link
Contributor Author

Thank you. One more question: what is the recommended test for a point in infinity, which is returned when there is no intersection?

@jan-mue
Copy link
Owner

jan-mue commented Sep 27, 2021

Thank you. One more question: what is the recommended test for a point in infinity, which is returned when there is no intersection?

Points at infinity are exactly those that have a zero in their last coordinate. For convenience I added the property isinf to the Point class that checks if the last coordinate is close to zero.

@pauljurczak
Copy link
Contributor Author

Which is the last coordinate? This snippet:

c = Cylinder()
l = Line(Point(3, 3, 2), Point(3, 3, 3))
print(c.intersect(l))

produces:

[Point(0j, 0j, (-0.7276068751089989+0.6859943405700353j)) at Infinity]

with non-zero last coordinate.

@jan-mue
Copy link
Owner

jan-mue commented Sep 27, 2021

Which is the last coordinate? This snippet:

c = Cylinder()
l = Line(Point(3, 3, 2), Point(3, 3, 3))
print(c.intersect(l))

produces:

[Point(0j, 0j, (-0.7276068751089989+0.6859943405700353j)) at Infinity]

with non-zero last coordinate.

The last coordinate is not shown in the standard string representation of a point. Instead "at Infinity" is added when it is close to zero. You can see all the homogeneous coordinates like this: print(c.intersect(l)[0].array). You can also directly access the last coordinate like this: print(c.intersect(l)[0][-1]).

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