Example #1
0
// 判断点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()));
    }
}
Example #2
0
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();
}
Example #3
0
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();
}
Example #4
0
File: main.cpp Project: gahr/tol
int
main(int argc, char ** argv)
{
    Tol t { argc, argv };
    return t.Run();
}
Example #5
0
// 判断两个矢量是否平行
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());
}
Example #6
0
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();
}
Example #7
0
// 判断点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();
}