Skip to content

Instantly share code, notes, and snippets.

View kavicastelo's full-sized avatar
💻
Living in a program

kavi castelo kavicastelo

💻
Living in a program
View GitHub Profile
@kavicastelo
kavicastelo / util-elastic-collision.js
Created November 28, 2023 16:55 — forked from christopher4lis/util-elastic-collision.js
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
*/