SkillAgentSearch skills...

TriangleBox.js

Implements collision between triangles and AABBs through the separating axis theorem (SAT).

Install / Use

/learn @kdrnic/TriangleBox.js
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

TriangleBox.js

Implements collision between triangles and AABBs through the separating axis theorem (SAT).

The function provides not only a boolean test (does the AABB overlap the triangle?) but also a least translation vector that solves the collision by moving the box to a non-overlapping position with the minimum possible displacement.

This code was written with the aid of the book "Real-time collision detection" by Christer Ericson. It's a rather good book. See page 169 for AABB-triangle.

The main difference between this solution and the one in the book is that this one normalizes the axes before calculating distances to give you the least translation vector, this makes this solution much more useful for game development.

See live interactive demo at https://dcbc94ebc2bed8001aa8ecb83eb9ddcaa9d17090.googledrive.com/host/0B9scOMN0JFaXb0Q1VUhCWUswRUE/test.html

View on GitHub
GitHub Stars10
CategoryDevelopment
Updated2y ago
Forks1

Languages

JavaScript

Security Score

75/100

Audited on Jul 21, 2023

No findings