コード例 #1
0
ファイル: mglnrel.cpp プロジェクト: thinkfeed/touchvg
// 判断点pt是否在线段ab上
GEOMAPI bool mgIsBetweenLine2(
    const Point2d& a, const Point2d& b, const Point2d& pt, const Tol& tol)
{
    if (!mgIsColinear2(a, b, pt, tol))
        return false;
    
    // If ab not vertical, check betweenness on x; else on y.
    if (a.x != b.x) 
    {
        return ((a.x <= pt.x + tol.equalPoint()) 
            && (pt.x <= b.x + tol.equalPoint())) 
            || ((a.x >= pt.x - tol.equalPoint()) 
            && (pt.x >= b.x - tol.equalPoint()));
    }
    else
    {
        return ((a.y <= pt.y + tol.equalPoint()) 
            && (pt.y <= b.y + tol.equalPoint())) 
            || ((a.y >= pt.y - tol.equalPoint()) 
            && (pt.y >= b.y - tol.equalPoint()));
    }
}
コード例 #2
0
ファイル: mglnrel.cpp プロジェクト: arthur-zhang/touchvg
bool mglnrel::isColinear2(
    const Point2d& a, const Point2d& b, const Point2d& pt, const Tol& tol)
{
    float dist = (b-a).crossProduct(pt-a);
    return fabsf(dist) < tol.equalPoint();
}
コード例 #3
0
ファイル: mglnrel.cpp プロジェクト: arthur-zhang/touchvg
bool mglnrel::isLeftOn2(
    const Point2d& a, const Point2d& b, const Point2d& pt, const Tol& tol)
{
    float dist = (b-a).distanceToVector(pt-a);
    return dist > -tol.equalPoint();
}
コード例 #4
0
ファイル: main.cpp プロジェクト: gahr/tol
int
main(int argc, char ** argv)
{
    Tol t { argc, argv };
    return t.Run();
}
コード例 #5
0
ファイル: mgvec.cpp プロジェクト: arthur-zhang/touchvg
// 判断两个矢量是否平行
bool Vector2d::isParallelTo(const Vector2d& vec, const Tol& tol) const
{
    float cosfz = dotProduct(vec);
    float sinfz = crossProduct(vec);
    return (fabsf(sinfz) <= fabsf(cosfz) * tol.equalVector());
}
コード例 #6
0
ファイル: mgmat.cpp プロジェクト: Vito2015/vgcore
bool Matrix2d::isEqualTo(const Matrix2d& mat, const Tol& tol) const
{
    return mgHypot(m11 - mat.m11, m12 - mat.m12) <= tol.equalVector()
        && mgHypot(m21 - mat.m21, m22 - mat.m22) <= tol.equalVector()
        && mgHypot(dx - mat.dx, dy - mat.dy) <= tol.equalVector();
}
コード例 #7
0
ファイル: mglnrel.cpp プロジェクト: thinkfeed/touchvg
// 判断点pt是否在有向直线a->b的左边
GEOMAPI bool mgIsLeft2(
    const Point2d& a, const Point2d& b, const Point2d& pt, const Tol& tol)
{
    float dist = (b-a).distanceToVector(pt-a);
    return dist > tol.equalPoint();
}