📄 fixutil.cpp
字号:
#include "FixUtil.h"
#include <config.h>
//Returns whether the point (x, y) is right from the line (a, b) or not
bool FixUtil::getPointLineSide( Fix x, Fix y, const FixVec2& a, const FixVec2& b )
{
x -= a.x;
y -= a.y;
Fix otherx = b.x - a.x;
Fix othery = b.y - a.y;
return x*othery-y*otherx <= Fix(0);
}
bool FixUtil::testLineLineIntersection(
const FixVec2& a0, const FixVec2& a1,
const FixVec2& b0, const FixVec2& b1 )
{
Fix n1 = (b1.x-b0.x)*(a0.y-b0.y) - (b1.y-b0.y)*(a0.x-b0.x);
Fix n2 = (a0.y-b0.y)*(a1.x-a0.x) - (a0.x-b0.x)*(a1.y-a0.y);
Fix dn = (a1.x-a0.x)*(b1.y-b0.y) - (a1.y-a0.y)*(b1.x-b0.x);
if ( dn.v > 0 )
return n1.v < dn.v && n2.v < dn.v && n1.v > 0 && n2.v > 0;
else if ( dn.v < 0 )
return n1.v > dn.v && n2.v > dn.v && n1.v < 0 && n2.v < 0;
return false;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -