小编Ale*_*lex的帖子

分离轴定理让我疯了!

我正在研究用于2D游戏的Separting Axis定理的实现.它有点工作,但只是一种.

我这样使用它:

bool penetration = sat(c1, c2) && sat(c2, c1);
Run Code Online (Sandbox Code Playgroud)

其中c1c2类型Convex,定义为:

class Convex
{
public:
    float tx, ty;
public:
    std::vector<Point> p;
    void translate(float x, float y) {
        tx = x;
        ty = y;
    }
};
Run Code Online (Sandbox Code Playgroud)

(Point是结构float x,float y)

这些点是顺时针输入的.

我当前的代码(忽略Qt调试):

bool sat(Convex c1, Convex c2, QPainter *debug)
{
    //Debug
    QColor col[] = {QColor(255, 0, 0), QColor(0, 255, 0), QColor(0, 0, 255), QColor(0, 0, 0)};
    bool ret = …
Run Code Online (Sandbox Code Playgroud)

c++ math geometry linear-algebra

9
推荐指数
1
解决办法
2499
查看次数

标签 统计

c++ ×1

geometry ×1

linear-algebra ×1

math ×1