Skip to main content
100%

Collision detection in transition

✓ Published0🌍 Public
Aahmohamed
Last edited Feb 21, 2015
Created on Feb 21, 2015

A moving circle travels along a closed cardinal-interpolated path defined by seven fixed points, changing color to red when it overlaps any of those points and returning to steel blue when it clears them. The visualization adapts Mike Bostock’s point-along-path interpolation example, using a D3 v3 transition with a custom tween function that calls `getPointAtLength` on the SVG path element to update the circle’s position. Collision detection compares axis-aligned bounding boxes of the moving and stationary circles via their `transform` attributes, applying the fill style directly within the tween.

AI-generated description

This is a modification of Mike's example "Point-Along-Path Interpolation". Here, we detect when the moving circle "collides" with one of the stationary points.

Similar vizzes