Ultrasonic array imaging for NDE based on Full Matrix Capture (FMC) and Total Focusing Method (TFM) imaging requires the calculation of ray paths and transit times from each array element to each image point. For direct contact inspection of homogeneous material this is trivial since the ray path is a straight line and anisotropy can be readily included by using the group velocity of the material at the appropriate angle. For more complex cases where mode conversions, refractions and reflections are involved, the ray path calculation is more challenging as the ray-path consists of multiple straight line segments connecting unknown intermediate points at each interface. Material that does not have translationally-invariant properties, such as curved composites and austenitic weld metal, adds further complexity as the ray-path segments are not themselves straight lines. In this paper a general, scalable method that can be applied to all these situations is presented. The method is based on the Fermat minimum time principle, implemented in a computationally-efficient way based on a modified form of Dijkstra’s algorithm. The same approach can also be used to compute ray-paths in simulations of the forward problem. Simulated and experimental results will be shown from a variety of geometries.