Skip to content

Instantly share code, notes, and snippets.

@EduardoJM
Created July 11, 2020 17:59
Show Gist options
  • Save EduardoJM/bf389619b058653fc738b6f02ee018ea to your computer and use it in GitHub Desktop.
Save EduardoJM/bf389619b058653fc738b6f02ee018ea to your computer and use it in GitHub Desktop.
Separating Axis Theorem Polygon Offset
polygon.offset = function(dx, dy) {
for (let i = 0; i < polygon.vertices.length; i++) {
polygon.vertices[i] = {
x: polygon.vertices[i].x + dx,
y: polygon.vertices[i].y + dy,
};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment