Translation direction in separating axis theorem

笑着哭i 提交于 2019-12-04 20:12:14

My solution:

I substract the center vector R1 from center Vector R2, build the dot product to the tested axis and invert the translation if the dotproduct is smaller then 0

Vector centerR1(R1.x,R1.y);
Vector centerR2(R2.x,R2.y);

Vector R1toR2 = centerR2 - centerR1;

if(R1toR2.dot(axis)<0){
  translation = -translation
}

"When the vector (R1toR2) points in an negative direction, invert the translation"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!