2929# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030# POSSIBILITY OF SUCH DAMAGE.
3131
32- # TODO: add docstrings
33-
3432cimport cython
3533from libc.math cimport INFINITY
3634from raysect.core.math cimport new_point3d, new_point2d
@@ -143,7 +141,7 @@ cdef class BoundingBox3D:
143141 0.5 * (self .lower.z + self .upper.z)
144142 )
145143
146- cpdef bint hit(self , Ray ray):
144+ cpdef bint hit(self , Ray ray) noexcept :
147145 """
148146 Returns true if the ray hits the bounding box.
149147
@@ -177,7 +175,7 @@ cdef class BoundingBox3D:
177175
178176 return hit, front_intersection, back_intersection
179177
180- cdef bint intersect(self , Ray ray, double * front_intersection, double * back_intersection):
178+ cdef bint intersect(self , Ray ray, double * front_intersection, double * back_intersection) noexcept :
181179
182180 # set initial ray-slab intersection search range
183181 front_intersection[0 ] = - INFINITY
@@ -198,7 +196,7 @@ cdef class BoundingBox3D:
198196 return True
199197
200198 @ cython.cdivision (True )
201- cdef void _slab(self , double origin, double direction, double lower, double upper, double * front_intersection, double * back_intersection) nogil:
199+ cdef void _slab(self , double origin, double direction, double lower, double upper, double * front_intersection, double * back_intersection) noexcept nogil:
202200
203201 cdef double reciprocal, tmin, tmax
204202
@@ -244,7 +242,7 @@ cdef class BoundingBox3D:
244242 if tmax < back_intersection[0 ]:
245243 back_intersection[0 ] = tmax
246244
247- cpdef bint contains(self , Point3D point):
245+ cpdef bint contains(self , Point3D point) noexcept :
248246 """
249247 Returns true if the given 3D point lies inside the bounding box.
250248
@@ -299,7 +297,7 @@ cdef class BoundingBox3D:
299297 self .upper.y = max (self .upper.y, point.y + padding)
300298 self .upper.z = max (self .upper.z, point.z + padding)
301299
302- cpdef double surface_area(self ):
300+ cpdef double surface_area(self ) noexcept :
303301 """
304302 Returns the surface area of the bounding box.
305303
@@ -314,7 +312,7 @@ cdef class BoundingBox3D:
314312
315313 return 2 * (dx * dy + dx * dz + dy * dz)
316314
317- cpdef double volume(self ):
315+ cpdef double volume(self ) noexcept :
318316 """
319317 Returns the volume of the bounding box.
320318
@@ -359,7 +357,7 @@ cdef class BoundingBox3D:
359357 else :
360358 raise ValueError (" Axis must be in the range [0, 2]." )
361359
362- cpdef int largest_axis(self ):
360+ cpdef int largest_axis(self ) noexcept :
363361 """
364362 Find the largest axis of this bounding box.
365363
@@ -386,7 +384,7 @@ cdef class BoundingBox3D:
386384
387385 return largest_axis
388386
389- cpdef double largest_extent(self ):
387+ cpdef double largest_extent(self ) noexcept :
390388 """
391389 Find the largest spatial extent across all axes.
392390
@@ -478,7 +476,6 @@ cdef class BoundingBox2D:
478476 self .upper = upper
479477
480478 def __repr__ (self ):
481-
482479 return " BoundingBox2D({}, {})" .format(self .lower, self .upper)
483480
484481 def __getstate__ (self ):
@@ -517,7 +514,7 @@ cdef class BoundingBox2D:
517514 def upper (self , Point2D value not None ):
518515 self .upper = value
519516
520- cpdef bint contains(self , Point2D point):
517+ cpdef bint contains(self , Point2D point) noexcept :
521518 """
522519 Returns true if the given 2D point lies inside the bounding box.
523520
@@ -562,7 +559,7 @@ cdef class BoundingBox2D:
562559 self .upper.x = max (self .upper.x, point.x + padding)
563560 self .upper.y = max (self .upper.y, point.y + padding)
564561
565- cpdef double surface_area(self ):
562+ cpdef double surface_area(self ) noexcept :
566563 """
567564 Returns the surface area of the bounding box.
568565
@@ -598,7 +595,7 @@ cdef class BoundingBox2D:
598595 else :
599596 raise ValueError (" Axis must be in the range [0, 1]." )
600597
601- cpdef int largest_axis(self ):
598+ cpdef int largest_axis(self ) noexcept :
602599 """
603600 Find the largest axis of this bounding box.
604601
@@ -619,7 +616,7 @@ cdef class BoundingBox2D:
619616
620617 return largest_axis
621618
622- cpdef double largest_extent(self ):
619+ cpdef double largest_extent(self ) noexcept :
623620 """
624621 Find the largest spatial extent across all axes.
625622
0 commit comments