separating-axis-test
Version:
test for the intersection of convex polytopes in 2d or 3d, computing the minimum translation vector
18 lines (17 loc) • 431 B
JavaScript
var sat3d = require('../3d.js')
var A = {
separatingAxes: [[0,0,1],[0,1,0],[1,0,0]],
positions: [
[0,0,0],[0,1,0],[1,1,0],[1,0,0],
[0,0,1],[0,1,1],[1,1,1],[1,0,1]
]
}
var B = {
separatingAxes: [[0,0,1],[0,1,0],[1,0,0]],
positions: [
[-0.5,0.4,0],[0.5,0.4,0],[0.5,-0.6,0],[-0.5,-0.6,0],
[-0.5,0.4,1],[0.5,0.4,1],[0.5,-0.6,1],[-0.5,-0.6,1]
]
}
var out = [0,0,0]
console.log(sat3d(out, A, B)) // [0,0.4,0]