How to do c# collision detection?

后端 未结 4 938
难免孤独
难免孤独 2021-01-06 18:08

Are there any predefined methods in c# which allow for collision detection?

I am new to c# and am trying to get collision detection of two ellipses are there any pre

4条回答
  •  隐瞒了意图╮
    2021-01-06 18:15

    Would something like the following work?

    var ellipse1Geom = ellipse1.RenderedGeometry;
    var ellipse2Geom = ellipse2.RenderedGeometry;
    var detail = ellipse1Geom.FillContainsWithDetail(ellipse2Geom);
    if(detail != IntersectionDetail.Empty)
    {
        // We have an intersection or one contained inside the other
    }
    

    The Geometry.FillContainsWithDetail(Geometry) method is defined as

    Returns a value that describes the intersection between the current geometry and the specified geometry.

提交回复
热议问题