Skip to content

Instantly share code, notes, and snippets.

View gyopiazza's full-sized avatar

Giordano Piazza gyopiazza

View GitHub Profile
@christopher4lis
christopher4lis / util-elastic-collision.js
Last active August 22, 2024 15:25
A set of utility functions used to reproduce the effect of elastic collision within HTML5 canvas. Used in the Chris Courses tutorial video on collision detection: https://www.youtube.com/watch?v=789weryntzM
/**
* Rotates coordinate system for velocities
*
* Takes velocities and alters them as if the coordinate system they're on was rotated
*
* @param Object | velocity | The velocity of an individual particle
* @param Float | angle | The angle of collision between two objects in radians
* @return Object | The altered x and y velocities after the coordinate system has been rotated
*/