Collision detection, a.k.a. train crashes

As designed, my locomotives are ætheral beings, able to glide seamlessly and smoothly through each other. To prevent this, we need to detect collision or interference. SVG does have some primitive collision detection based on bounding box overlap, but given the isometric 3D nature of our engines, this is unlikley to be accurate, and certainly over-enthusiastic. Moreover, normal movement of our engines is both highly restrained, i.e. to track sections, and predictable, as they travel at known rates.

A simple approach, ignoring engine size and treating them as point entities, is to consider only cases where two (or more) engines are in the same section[23], travelling in either the same or opposite directions. Such a case can be checked when either a locomotive enters a new section, or the speed of an engine is changed. In such circumstances, we know both where, in distance, each locomotive is, and how fast they are approaching each other. Hence in the case of a predicted collision we can schedule an action (using ixsl:scheduleAction) to trigger a crash notification after the required interval. However there is also the difficulty of a subsequent speed change altering this — this requires the ability to delete some of the currently active scheduled actions, which has proved highly problematic.



[23] Much of nineteenth-century railway signalling development was of course to stop such a situation happening in the first place.