find_limbs¶
- giant.ray_tracer.utilities.find_limbs(shape, scan_center_dir, scan_dirs, observer_position=None, initial_step=1, max_iterations=25, rtol=1e-12, atol=1e-12)[source]¶
This helper function determines the limb points for any traceable shape (visible edge of the shape) that would be visible for an observer located at
observer_position
looking towardscan_center_dir
along the directions given byscan_dirs
.Typically it is assumed that the location of the observer is at the origin of the current frame and therefore
observer_position
can be left asNone
.The limb for the surface is found iteratively by tracing rays from the observer to the shape. First, the rays are traced along the scan center direction, which should beg guaranteed to strike the shape. Then, we adjust the direction of the rays so that they no longer intersect the surface using
initial_step
. We then proceed by tracing rays with directions half way between the left rays (guaranteed to strike the surface) and the right rays (guaranteed to not strike the surface) updating the left and right rays based on the result of the last trace. This continues for a maximum ofmax_iterations
or until the tolerances specified byrtol
andatol
are met for the change in the estimate of the limb location. The returned limb location is the last ray intersect location that hit the surface for eachscan_dirs
.The returned limbs are expressed as vectors from the observer to the limb point in the current frame as a 3xn numpy array.
- Parameters:
shape (Shape) – The target shape that we are to find the limb points for as a
Shape
scan_center_dir (Sequence | ndarray) – the unit vector which the scan is to begin at in the current frame as a length 3 array A ray cast along this unit vector from the
observer_position
should be guaranteed to strike the surface and ideally should be towards the center of figure of the surfacescan_dirs (Sequence | ndarray) – the unit vectors along with the scan is to proceed as a 3xn array in the current frame where each column represents a new limb point we wish to find (should be nearly orthogonal to the
scan_center_dir
in most cases).observer_position (Sequence | ndarray | None) – The location of the observer in the current frame. If
None
then it is assumed the observer is at the origin of the current frameinitial_step (Real) – The size of the initial step to take along the
scan_dirs
direction. This should be guaranteed to result in rays that do not strike the body.max_iterations (int) – The maximum number of iteration steps to take when locating the limbs
rtol (Real) – The relative tolerance of the change in the limb location from one iteration to the next that indicates convergence.
atol (Real) – the absolute tolerance of the change int he limb location from one iteration to the next that indicates convergence.
- Returns:
the vectors from the observer to the limbs in the current frame as a 3xn array
- Return type:
ndarray