   Rotated swept capsule intersection time
  Hi, some rather weird problem i have here, i need to calculate maximum extent that given capsule can go in either clockwise or counterclockwise direction when rotating around center of one circle making capsule and intersecting with either line or other capsule. But lets better skip the capsule for now...I'm thinking about doing separate tests for circle, rotating around some origin (that in this case would be other circles center that make up lower par of capsule in picture) and another test for line, rotating around the same origin as circle.   
  phew... rotational motions can be nasty if you want an exact result (solve some equations). Else, there is always conservative advancement, but it is slow (potentially lots of iterations) and not as accurate. If you consider a segment and a capsule, they are essentially the same thing, a capsule is a segment with a radius. A segment is a capsule with a radius of 0. Similarly, a circle is a capsule with a length of zero.Maybe there is a way to kill three birds with one stone there... or not.   ;  Taking from http://mathworld.wolfram.com/Circle-LineIntersection.htmlLine intersects circle in one point (tangent) when discriminant (or some kind of delta? I'm not familiar with that notation they are using lol) is zero. So i thought if i could somehow manage to smack that circle intersection stuff together with angle (or call it time) based formula for circle position there could be way to get that solved.So we need that r^2 + dr^2 + D^2 = 0Just need to somehow smack in formula for circle position regarding angle in dx, dy, and D variables (define dx and dy like functions that return position on circle if we give in angle?)But im not familiar doing this work and not familiar how swept calculations are done in general, I would be very happy if someone could help me with that ^^;EDIT - but probably yeah, i will do much better if i could find swept line segment - line segment case and find intersection then if distance between them is capsule radius not 0 as it would be in normal case. And then maybe i could replace position with function over angle and create a nice angle based sweep test...[Edited by - Semei on June 20, 2009 4:10:38 AM];  the problem is circular motion. Doing swept test involved talking derivatives of equations, and derivatives of trigonometric functions are tricky to solve.Another way for a moving circle is to decompose the overall motion into several small linear motions. Then it is quite easy. It's a number of swept circle / line tests.   ;  This shouldn't require any swept motion.. it should be quite easy actually.Consider the easier rotating line against line intersection, which has two possibilities for collision, shown in the image below. Either the end-point of the rotating line rotates into the other line, or the actual line rotates into the other line's endpoint, which is exactly the same as that the other line's endpoint rotates into the rotating line. In the image the green point is the rotation center, and the blue line is the radius of the circle.To solve this there needs to be no swept or rotating motion, just do a simple line-circle intersection, which will give you either 0, 1, or 2 points of intersection. Then check the angle of the rotating line, as in a unit circle, where straight to the right is 0 degrees, and straight to the left is 180 etc, and do the same with the line from the rotation center to the collision point. Then check if the angle difference is smaller than the angle that you want to rotate, and if that is so, then a collision has occurred at time (angleDifference / angleToRotate) * timeToRotate'angleToRotate'.To move to the capsule case we get the cases in the following image, which can be solved just the same as above. Just test against a line offset with a radius.The last case is the rotating point to circle intersection, which is shown in this last image.Again, just perform a simple check in the form of a circle to circle intersection. Then check the angles, of the lines from the rotation origin to those points, and again check if the angle difference from the rotating line is less than the angle you want to rotate.This image shows what I mean with the angles.;  see, why complicate things. There's a solution to everything!   ;  Hey! You are saying that i should test it in one position and the test if angle are inside range i want... But i want to know potential collision - for example the green capsule represents capsule starting angle and i want to test in what angle collision will take place if i rotate it in counterclockwise direction. Collision then will occur when capsule is rotated to red position. So in simple words i want to know how far from current angle i have i can go in one direction till intersection happens...EDIT : Oh, Yes! I think i got it now, just thought that those circles represent starting positions but they are constructed and then tested against lines as you explained! Great! Will try to implement this now...[Edited by - Semei on June 20, 2009 3:13:45 PM]