   Moving Sphere -> Line segment
  Is there anyway, relatively cheap, to control *when* in a move a sphere collides with a line segment, that works for all cases?basically, you *could* just use the move and the line as rays, and get a point where the distance between them equals the radius of the sphere, but this doesn''t take into account the edges of the line segment.... So basically, my question would be- is there any way to find all points on a ray that is of a given distance from a line segment?Thanks. 
  Intersect the ray with a capsule with an Axis=Segment and a Radius=Sphere.Radiusdouble Capsule::Intersect(const Vector3D &Point, const Vector3D &Vector) const{if(Contains(Point))// If the capsule contains the point,return -1.0;// Return a negative numberVector3D UnitLine((Axis.EndPoint[1]-Axis.EndPoint[0]).unit());// Unit Vector Representing the Axisdouble Parallel=Dot(UnitLine,Vector);// Length of parallel component of VectorVector3D Perp(Vector-(UnitLine*Parallel));// Perpendicular Vector to AxisVector3D Relative(Point-Axis.EndPoint[0]);// Vector representing the point relative to EndPoint 0double LineDist=Dot(UnitLine,Relative);// The Distance along the line from EndPoint 0 to the closest pointVector3D Closest(UnitLine*LineDist);// The Vector representing the Closest point on the Infinite Cylinder relative to EndPoint 0if((Relative-Closest).Length(){// We only have to test the endsif(Closest.Length()<0.0)// If the closest point is Endpoint0,return Sphere(Axis.EndPoint[0],Radius).Intersect(Point,Vector);// Intersect the Vector with a sphere surrounding Endpoint0else if(Closest.Length()>Axis.Length())// If the closest point is Endpoint1,return Sphere(Axis.EndPoint[1],Radius).Intersect(Point,Vector);// Intersect the Vector with a sphere surrounding Endpoint1}// If the point was not inside the infinite cylinder, we continuedouble CrossDist=Sphere(Closest,Radius).Intersect(Relative,Perp);// Intersect the Perpendicular Vector to the cross-section of the Infinite Cylinderif(CrossDist<0.0)// If this distance is negative, there was no intersection with the curved surface of the Infinite Cylinder,return CrossDist;// So we return a negative numberdouble Percent=CrossDist/Perp.Length();// The Percent of Vector until the intersectionVector3D CollVect(Vector);// The Vector to the intersectionCollVect*=Percent;// After it is multiplied by the Percent of Vector until the intersectionVector3D CollPoint(Point+CollVect);// The Point of intersection with the infinite cylinderRelative=CollPoint-Axis.EndPoint[0];// Vector representing the intersection point relative to EndPoint 0double CollDist=Dot(UnitLine,Relative);// The Distance along the line from EndPoint 0 to the closest point on the Axis to the intersection pointif(CollDist>0.0 && CollDistreturn CollVect.Length();// Return the distance to the intersection// If the closest point does not lie along the axis, check for collisions with the rounded endselse if(CollDist<0.0)// If the closest point is Endpoint0,return Sphere(Axis.EndPoint[0],Radius).Intersect(Point,Vector);// Intersect the Vector with a sphere surrounding Endpoint0else if(CollDist>Axis.Length())// If the closest point is Endpoint1,return Sphere(Axis.EndPoint[1],Radius).Intersect(Point,Vector);// Intersect the Vector with a sphere surrounding Endpoint1return -1.0;// If this point was reached, there was an error, so we return a negative number}  --------------------------------------I am the master of stories.....If only I could just write them down... ;  Some of the code was cut off!! Grrr! I''m sure you can figure it out...   --------------------------------------I am the master of stories.....If only I could just write them down... ;  what i always do is test against the linesegemt, disregard the results if the sphere passes beyond the endpoints and compensate for that by also checking against all vertices, it works just fine.uts probably what the above code does aswell, although i havnt checked it. ;  ...Thanks, that works in my mind. I''m not really sure what this line should *really* be:if((Relative-Closest).Length(){...but I''ll guess I''ll find out when I try to implement it. 