示例#1
0
        internal float Evaluate(XForm transformA, XForm transformB)
        {
            switch (FaceType)
            {
            case Type.Points:
            {
                Vec2  axisA       = Common.Math.MulT(transformA.R, Axis);
                Vec2  axisB       = Common.Math.MulT(transformB.R, -Axis);
                Vec2  localPointA = ShapeA.GetSupportVertex(axisA);
                Vec2  localPointB = ShapeB.GetSupportVertex(axisB);
                Vec2  pointA      = Common.Math.Mul(transformA, localPointA);
                Vec2  pointB      = Common.Math.Mul(transformB, localPointB);
                float separation  = Vec2.Dot(pointB - pointA, Axis);
                return(separation);
            }

            case Type.FaceA:
            {
                Vec2 normal = Common.Math.Mul(transformA.R, Axis);
                Vec2 pointA = Common.Math.Mul(transformA, LocalPoint);

                Vec2 axisB = Common.Math.MulT(transformB.R, -normal);

                Vec2 localPointB = ShapeB.GetSupportVertex(axisB);
                Vec2 pointB      = Common.Math.Mul(transformB, localPointB);

                float separation = Vec2.Dot(pointB - pointA, normal);
                return(separation);
            }

            case Type.FaceB:
            {
                Vec2 normal = Common.Math.Mul(transformB.R, Axis);
                Vec2 pointB = Common.Math.Mul(transformB, LocalPoint);

                Vec2 axisA = Common.Math.MulT(transformA.R, -normal);

                Vec2 localPointA = ShapeA.GetSupportVertex(axisA);
                Vec2 pointA      = Common.Math.Mul(transformA, localPointA);

                float separation = Vec2.Dot(pointA - pointB, normal);
                return(separation);
            }

            default:
                Box2DNetDebug.Assert(false);
                return(0.0f);
            }
        }
        internal float Evaluate(Transform TransformA, Transform TransformB)
        {
            switch (FaceType)
            {
            case Type.Points:
            {
                Vector2 axisA       = TransformA.InverseTransformDirection(Axis);
                Vector2 axisB       = TransformB.InverseTransformDirection(-Axis);
                Vector2 localPointA = ShapeA.GetSupportVertex(axisA);
                Vector2 localPointB = ShapeB.GetSupportVertex(axisB);
                Vector2 pointA      = TransformA.TransformPoint(localPointA);
                Vector2 pointB      = TransformB.TransformPoint(localPointB);
                float   separation  = Vector2.Dot(pointB - pointA, Axis);
                return(separation);
            }

            case Type.FaceA:
            {
                Vector2 normal = TransformA.TransformDirection(Axis);
                Vector2 pointA = TransformA.TransformPoint(LocalPoint);

                Vector2 axisB = TransformB.InverseTransformDirection(-normal);

                Vector2 localPointB = ShapeB.GetSupportVertex(axisB);
                Vector2 pointB      = TransformB.TransformPoint(localPointB);

                float separation = Vector2.Dot(pointB - pointA, normal);
                return(separation);
            }

            case Type.FaceB:
            {
                Vector2 normal = TransformB.TransformDirection(Axis);
                Vector2 pointB = TransformB.TransformPoint(LocalPoint);

                Vector2 axisA = TransformA.InverseTransformDirection(-normal);

                Vector2 localPointA = ShapeA.GetSupportVertex(axisA);
                Vector2 pointA      = TransformA.TransformPoint(localPointA);

                float separation = Vector2.Dot(pointA - pointB, normal);
                return(separation);
            }

            default:
                Box2DNetDebug.Assert(false);
                return(0.0f);
            }
        }