示例#1
0
    static public bool overlap(SceneShapeLine shape1, SceneShapeRound shape2)
    {
        LineSegf line = new LineSegf(new Vector2f(shape1.mVertex1.x, shape1.mVertex1.y), new Vector2f(shape1.mVertex2.x, shape1.mVertex2.y));

        Vector2f tarPos = Geometryalgorithm2d.point_line_intersect(new Vector2f(shape2.mCenter.x, shape2.mCenter.y), line);

        return((tarPos.Subtract(new Vector2f(shape2.mCenter.x, shape2.mCenter.y))).length() <= shape2.mRadius);
    }
示例#2
0
    static public bool overlap(SceneShapeLine shape1, SceneShapePolygon shape2)
    {
        LineSegf line = new LineSegf(new Vector2f(shape1.mVertex1.x, shape1.mVertex1.y), new Vector2f(shape1.mVertex2.x, shape1.mVertex2.y));

        for (int i = 1; i < shape2.mPts.Count; i++)
        {
            Vector2f p1 = new Vector2f(shape2.mPts[i - 1].x, shape2.mPts[i - 1].y);
            Vector2f p2 = new Vector2f(shape2.mPts[i].x, shape2.mPts[i].y);

            if (Geometryalgorithm2d.lineseg_intersect_lineseg(line, new LineSegf(p1, p2)))
            {
                return(true);
            }
        }

        return(false);
    }
示例#3
0
 static public bool overlap(SceneShapeLine shape1, SceneShapeRect shape2)
 {
     return(Geometryalgorithm2d.lineseg_intersect_rectangle(
                new LineSegf(new Vector2f(shape1.mVertex1.x, shape1.mVertex1.y), new Vector2f(shape1.mVertex2.x, shape1.mVertex2.y)),
                new Rectanglef(new Vector2f(shape2.leftBottom().x, shape2.leftBottom().y), new Vector2f(shape2.rightTop().x, shape2.rightTop().y))));
 }
示例#4
0
 static public bool overlap(SceneShapeLine shape1, SceneShapeLine shape2)
 {
     return(Geometryalgorithm2d.lineseg_intersect_lineseg(
                new LineSegf(new Vector2f(shape1.mVertex1.x, shape1.mVertex1.y), new Vector2f(shape1.mVertex2.x, shape1.mVertex2.y)),
                new LineSegf(new Vector2f(shape2.mVertex1.x, shape2.mVertex1.y), new Vector2f(shape2.mVertex2.x, shape2.mVertex2.y))));
 }