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

Meet fails when line intersects sphere at only one point #429

Open
kaluzaklein opened this issue Feb 26, 2024 · 0 comments
Open

Meet fails when line intersects sphere at only one point #429

kaluzaklein opened this issue Feb 26, 2024 · 0 comments

Comments

@kaluzaklein
Copy link

kaluzaklein commented Feb 26, 2024

I get the error "LinAlgError: Array must not contain infs or NaNs." when trying to intersect an OPNS line with an OPNS sphere (OPNS = outer product null space represenation). Conversely, there is no error and the answer is correct when I intersect a line that meets at 2 places on the sphere, or a line that does not intersect the sphere.

Using clifford version 1.4.0

from clifford.g3c import layout
from clifford import Cl, conformalize

from clifford.tools.g3c import point_pair_to_end_points
from clifford.tools.g3c import up
from clifford import g3c

locals().update(g3c.blades)
locals().update(g3c.stuff)

r = 3.0
# Line with only 1 intersection point on sphere
sphere = eo + 5.0*e3 + 0.5*(25.0 - r**2)*einf
line = up(r*e1) ^ up(r*e1 + 1.0*e3) ^ einf

print(f"line = {line}")

pointpair = line.meet(sphere.dual())
print(pointpair.mag2())
end_points = point_pair_to_end_points(pointpair)

print(down(end_points[0]))
print(down(end_points[1]))

The output and error of this code is as follows:

line = (3.0^e134) + (3.0^e135) + (1.0^e345)
/usr/local/lib/python3.10/dist-packages/clifford/_multivector.py:281: RuntimeWarning: divide by zero encountered in divide
  newValue = self.value / other
/usr/local/lib/python3.10/dist-packages/clifford/_multivector.py:281: RuntimeWarning: invalid value encountered in divide
  newValue = self.value / other
---------------------------------------------------------------------------
LinAlgError                               Traceback (most recent call last)
[<ipython-input-35-2d6c45ab9902>](https://localhost:8080/#) in <cell line: 7>()
      5 print(f"line = {line}")
      6 
----> 7 pointpair = line.meet(sphere.dual())
      8 print(pointpair.mag2())
      9 end_points = point_pair_to_end_points(pointpair)

3 frames
[/usr/local/lib/python3.10/dist-packages/numba/np/linalg.py](https://localhost:8080/#) in _check_finite_matrix()
    825     for v in np.nditer(a):
    826         if not np.isfinite(v.item()):
--> 827             raise np.linalg.LinAlgError(
    828                 "Array must not contain infs or NaNs.")
    829 

LinAlgError: Array must not contain infs or NaNs.
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

1 participant