Esempio n. 1
0
        private bool OOBvsCircle(OrientedBoxBody box, CircleBody circle)
        {
            FixedPointVector3 rotated  = MathExt.RotatePoint(circle.position, box.position, 0);
            FixedPointVector3 relative = rotated - box.position;

            FixedPoint        halfW   = box.width * FixedPoint.Float05;
            FixedPoint        halfH   = box.height * FixedPoint.Float05;
            FixedPointVector3 clamped = new FixedPointVector3(
                relative.X.Clamp(-halfW, halfW),
                relative.Y.Clamp(-halfH, halfH),
                0);

            //rotate back
            FixedPointVector3 transformedBack = MathExt.RotatePoint(clamped, box.position, 0);

            transformedBack += box.position;

            return((circle.position - transformedBack).Magnitude <= circle.radius);
        }
Esempio n. 2
0
        //lets imagine lib provides FixedPointVector2
        private bool CircleVsCircle(CircleBody first, CircleBody second)
        {
            FixedPoint rSum = (first.radius + second.radius);

            return((first.position - second.position).Magnitude <= rSum * rSum);
        }