Ellipsoid.intersect

giant.ray_tracer.shapes.ellipsoid:

Ellipsoid.intersect(self, rays)

This method determines where the provides rays strike this tri-axial ellipsoid.

The results are returned as a nx3 numpy array of floats with each row corresponding to the nearest intersect location between the corresponding ray and the ellipsoid. Anywhere that the rays did not strike the ellipsoid the corresponding row is set to all NaN.

The intersects are determined by solving the following quadratic equation for \(d\):

\[ad^2+bd+c=0\]

where

\[\begin{split}a = \mathbf{d}^T\mathbf{A}_C\mathbf{d} \\ b = 2\mathbf{d}^T\mathbf{A}_C\left(\mathbf{s}-\mathbf{c}\right) \\ c = \left(\mathbf{s}-\mathbf{c}\right)^T\mathbf{A}_C\left(\mathbf{s}-\mathbf{c}\right)\end{split}\]

\(\mathbf{d}\) is the direction of the ray, \(\mathbf{s}\) is the start location for the ray, and \(\mathbf{c}\) is the center of the ellipsoid in the current frame. Solving this quadratic equation will give 2 distances. If both are imaginary (or both are negative) then no intersect occurs. Otherwise the smallest (positive) distance is taken as the closest intersect.

Only the intersection point is returned for each ray. To get all of the information (intersection point, surface normal, albedo, etc) see the trace() or compute_intersect() methods.

Parameters:

rays (Rays) – The rays to trace through the array

Returns:

A nx3 array (where n is the number of rays) with the closest intersect between the corresponding ray and the ellipsoid or NaN if no intersection occurs.

Type:

np.ndarray