Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. seprating axis swept;

seprating axis swept;

Scheduled Pinned Locked Moved C#
graphicsquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Isawyouoo
    wrote on last edited by
    #1

    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[^]

    M 1 Reply Last reply
    0
    • I Isawyouoo

      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[^]

      M Offline
      M Offline
      Matt T Heffron
      wrote on last edited by
      #2

      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

      I 1 Reply Last reply
      0
      • M Matt T Heffron

        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

        I Offline
        I Offline
        Isawyouoo
        wrote on last edited by
        #3

        anyway I can answer my post, it was the relative velocity, that make the right moment yep ;P

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups