Repository: DCC-Lab/RayTracing

Issue:
ImagingPath: chiefRay returns y=inf and theta=-inf with really big (but not infinite) aperture and no specific y given
When we create an `ImagingPath` with a really big aperture stop (but not infinite), the chief ray obtained has y = -theta = inf. This doesn't really make sense.

This happens because the aperture is bigger than the max height and at one point (in `fieldOfView`), if `abs(y) < self.maxHeight`, we return `float("+inf")`. If the aperture is bigger than the max height accepted, then we should consider it like an infite aperture?

Example:
```python
path = ImagingPath(System2f(10, 100_000)) # 2f system with f = 10 and 100_000 units aperture
print(path.chiefRay())
```
The output is:
```python
 /       \ 
|    inf  |
|         |
|   -inf  |
 \       /

z = 0.000
```

Discussion:

Patch:
diff --git a/raytracing/imagingpath.py b/raytracing/imagingpath.py
index eaea927..aa348eb 100644
--- a/raytracing/imagingpath.py
+++ b/raytracing/imagingpath.py
@@ -166,6 +166,8 @@ class ImagingPath(MatrixGroup):
 
         if y is None:
             y = self.fieldOfView()
+            if abs(y) == float("+inf"):
+                raise ValueError("Must provide y when the filed of view is infinite")
 
         return Ray(y=y, theta=-A * y / B)
 


Test patch:
diff --git a/raytracing/tests/testsImagingPath.py b/raytracing/tests/testsImagingPath.py
index 6590fe8..a6b39da 100644
--- a/raytracing/tests/testsImagingPath.py
+++ b/raytracing/tests/testsImagingPath.py
@@ -61,6 +61,12 @@ class TestImagingPath(unittest.TestCase):
         chiefRay = path.chiefRay()
         self.assertIsNone(chiefRay)
 
+    def testChiefRayInfiniteFieldOfViewNoY(self):
+        path = ImagingPath()
+        path.append(System2f(10, path.maxHeight + 1))
+        with self.assertRaises(ValueError):
+            path.chiefRay()
+
     def testMarginalRaysNoApertureStop(self):
         path = ImagingPath(System4f(10, 10))
         self.assertIsNone(path.marginalRays())