clifford
clifford copied to clipboard
Meet fails when line intersects sphere at only one point
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.