Index: Annulus.UnitTests/SweptCollisionDetection/RotatingPointvsRotatingSegmentTests.cs =================================================================== --- Annulus.UnitTests/SweptCollisionDetection/RotatingPointvsRotatingSegmentTests.cs (revision 955) +++ Annulus.UnitTests/SweptCollisionDetection/RotatingPointvsRotatingSegmentTests.cs (working copy) @@ -243,6 +243,72 @@ CheckEqual(0.25, segmentHitFraction); } + public void SlightlyComplexHit() + { + var hSqrt2 = Math.Sqrt(2) / 2; + var input = new RotatingPointvsRotatingSegment.Input + { + segment = new Line( + new Vector(-hSqrt2, hSqrt2), + new Vector(hSqrt2, hSqrt2) + ), + + initialLineOrientation = 0, + initialPointOrientation = -Math.PI, + initialPointPosition = new Vector(-3, 2), + lineAngularVelocity = Math.PI / 2, + pointAngularVelocity = Math.PI * 2, + pointLeverArm = new Vector(1, 0), + pointLinearVelocity = new Vector(4, -2), + impactWindow = new Interval(0, 100), + maxIterations = 1000, + }; + + Scalar timeOfImpact; + Scalar segmentHitFraction; + int iterations = 0; + var success = RotatingPointvsRotatingSegment.FindIntersection + (input, out timeOfImpact, out segmentHitFraction, ref iterations); + + CheckEqual(EndingState.SUCCESS, success); + CheckEqual(0.5, timeOfImpact); + CheckEqual(1, segmentHitFraction); + } + + public void SlightlyComplexHit_Acceleration() + { + // Combination of GrazingHit + var hSqrt2 = Math.Sqrt(2) / 2; + var input = new RotatingPointvsRotatingSegment.Input + { + segment = new Line( + new Vector(-hSqrt2, hSqrt2), + new Vector(hSqrt2, hSqrt2) + ), + + initialLineOrientation = 0, + initialPointOrientation = -Math.PI, + initialPointPosition = new Vector(-3, 2), + lineAngularVelocity = Math.PI / 2, + pointAngularVelocity = Math.PI * 2, + pointLeverArm = new Vector(1, 0), + pointLinearVelocity = new Vector(3, -2), + pointLinearAcceleration = new Vector(4, 0), + impactWindow = new Interval(0, 100), + maxIterations = 1000, + }; + + Scalar timeOfImpact; + Scalar segmentHitFraction; + int iterations = 0; + var success = RotatingPointvsRotatingSegment.FindIntersection + (input, out timeOfImpact, out segmentHitFraction, ref iterations); + + CheckEqual(EndingState.SUCCESS, success); + CheckEqual(0.5, timeOfImpact); + CheckEqual(1, segmentHitFraction); + } + public void MaxIterationsExceededOnce() { var input = new RotatingPointvsRotatingSegment.Input