seprating axis swept;
-
I didn't undersrand this code, is it for both moving polygons, (I said both) bool AxisSeparatePolygons ( Vector N, Polygon A, Polygon B, Vector Offset, Vector Vel, float &t, float tmax) { float min0, max0; float min1, max1; CalculateInterval(N, A, min0, max0); CalculateInterval(N, B, min1, max1); float h = Offset dot N; min0 += h; max0 += h; float d0 = min0 - max1; // if overlapped, do < 0 float d1 = min1 - max0; // if overlapped, d1 > 0 // separated, test dynamic intervals if (d0 > 0.0f || d1 > 0.0f) { float v = Vel dot N; // small velocity, so only the overlap test will be relevant. if (fabs(v) < 0.0000001f) return false; float t0 =-d0 / v; // time of impact to d0 reaches 0 float t1 = d1 / v; // time of impact to d0 reaches 1 // sort the times. if (t0 > t1) { float temp = t0; t0 = t1; t1 = temp; } // take the minimum positive taxis = (t0 > 0.0f)? t0 : t1; // intersection time too late or back in time, no collision if (taxis < 0.0f || taxis > tmax) return true; return false; } else { // overlap. get the interval, as a the smallest of |d0| and |d1| // return negative number to mark it as an overlap taxis = (d0 > d1)? d0 : d1; return false; } } it will only calculate time of velocity to overlap one of them to the other not both, but my exe make the right moment of collision, how that happens in sat? calculate next frame for both and use thales equation, because that's what I do. from http://elancev.name/oliver/2D%20polygon.htm[^]
-
I didn't undersrand this code, is it for both moving polygons, (I said both) bool AxisSeparatePolygons ( Vector N, Polygon A, Polygon B, Vector Offset, Vector Vel, float &t, float tmax) { float min0, max0; float min1, max1; CalculateInterval(N, A, min0, max0); CalculateInterval(N, B, min1, max1); float h = Offset dot N; min0 += h; max0 += h; float d0 = min0 - max1; // if overlapped, do < 0 float d1 = min1 - max0; // if overlapped, d1 > 0 // separated, test dynamic intervals if (d0 > 0.0f || d1 > 0.0f) { float v = Vel dot N; // small velocity, so only the overlap test will be relevant. if (fabs(v) < 0.0000001f) return false; float t0 =-d0 / v; // time of impact to d0 reaches 0 float t1 = d1 / v; // time of impact to d0 reaches 1 // sort the times. if (t0 > t1) { float temp = t0; t0 = t1; t1 = temp; } // take the minimum positive taxis = (t0 > 0.0f)? t0 : t1; // intersection time too late or back in time, no collision if (taxis < 0.0f || taxis > tmax) return true; return false; } else { // overlap. get the interval, as a the smallest of |d0| and |d1| // return negative number to mark it as an overlap taxis = (d0 > d1)? d0 : d1; return false; } } it will only calculate time of velocity to overlap one of them to the other not both, but my exe make the right moment of collision, how that happens in sat? calculate next frame for both and use thales equation, because that's what I do. from http://elancev.name/oliver/2D%20polygon.htm[^]
Is this C++ code? (The
float &t
is clearly NOT C#) This is in the wrong forum. It should be in: C / C++ / MFC[^]"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed." - G.K. Chesterton
-
Is this C++ code? (The
float &t
is clearly NOT C#) This is in the wrong forum. It should be in: C / C++ / MFC[^]"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed." - G.K. Chesterton