Posts Tagged ‘collision’

Code snippet – frame of collision

November 8, 2007

I whipped this little program in about an hour which helps you find the collision point of a circle to a line, and the normal in which it reflects. This principle works the same in 3D. You must have Java enabled in your browser to view the applet. The blue points connect the shortest distance between both lines, and the light blue circle shows the point of impact projected from the current path. Refreshing the applet makes a new random surface.

View applet

You can view the source files here: CircleLineCollision.pde Vert.pde
The code is written in Processing, but it’s easy to adapt to most common programming languages.

Advertisements