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. Other Discussions
  3. Clever Code
  4. Almost a complete waste of time

Almost a complete waste of time

Scheduled Pinned Locked Moved Clever Code
javascriptgame-devhelpquestion
8 Posts 7 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.
  • A Offline
    A Offline
    Anthony Mushrow
    wrote on last edited by
    #1

    I've spent the last couple of days working on some physics simulation for a car but I was having problems with stability, the car would kind of slide away very slowly and handling was, to put it lightly 'poor' The problem I found, was to do with the removal of angular velocity from the wheels (excluding the velocity around the axle). The code in question was this:

    if(lambda1 > EPSILON)
    {
    //remove velocity around axis
    }
    if(lambda2 > EPSILON)
    {
    //remove velocity around axis
    }

    Where lambda1 and lambda2 are the velocities around the two axis we don't want movement around, and checking against epsilon to avoid diving by zero. Shockingly I missed 50% of the cases where the velocities could be negative :doh: Two days I've spent wondering why the thing kept sliding off, two bloody days.

    if(FAbs(lambda1) > EPSILON)
    {
    //remove velocity around axis
    }
    if(FAbs(lambda2) > EPSILON)
    {
    //remove velocity around axis
    }

    Still, it's not all bad. In my quest to find the problem I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect. Now all that's left to do is tidy up the huge mess of code I've made.

    My current favourite word is: Smooth!

    -SK Genius

    D W C J 4 Replies Last reply
    0
    • A Anthony Mushrow

      I've spent the last couple of days working on some physics simulation for a car but I was having problems with stability, the car would kind of slide away very slowly and handling was, to put it lightly 'poor' The problem I found, was to do with the removal of angular velocity from the wheels (excluding the velocity around the axle). The code in question was this:

      if(lambda1 > EPSILON)
      {
      //remove velocity around axis
      }
      if(lambda2 > EPSILON)
      {
      //remove velocity around axis
      }

      Where lambda1 and lambda2 are the velocities around the two axis we don't want movement around, and checking against epsilon to avoid diving by zero. Shockingly I missed 50% of the cases where the velocities could be negative :doh: Two days I've spent wondering why the thing kept sliding off, two bloody days.

      if(FAbs(lambda1) > EPSILON)
      {
      //remove velocity around axis
      }
      if(FAbs(lambda2) > EPSILON)
      {
      //remove velocity around axis
      }

      Still, it's not all bad. In my quest to find the problem I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect. Now all that's left to do is tidy up the huge mess of code I've made.

      My current favourite word is: Smooth!

      -SK Genius

      D Offline
      D Offline
      DaveAuld
      wrote on last edited by
      #2

      Maybe that is one reason why when testing always pick the upper and lower bounds for the data type in question, helps quickly find things like this! I was on a Factory Acceptance Test for a oil platform controls and shutdown system a few years back, the lead engineer on the project thought i was taking the pi$$ when i asked him to start pumping in random extreme values. Comments like, 'Operator would do that would they?', and they got back comments like 'Wouldn't they?[in a sarcastic tone]' and 'What about typo errors when entering values under pressure?'

      Dave Don't forget to rate messages!
      Find Me On: Web|Facebook|Twitter|LinkedIn
      Waving? dave.m.auld[at]googlewave.com

      T Q 2 Replies Last reply
      0
      • A Anthony Mushrow

        I've spent the last couple of days working on some physics simulation for a car but I was having problems with stability, the car would kind of slide away very slowly and handling was, to put it lightly 'poor' The problem I found, was to do with the removal of angular velocity from the wheels (excluding the velocity around the axle). The code in question was this:

        if(lambda1 > EPSILON)
        {
        //remove velocity around axis
        }
        if(lambda2 > EPSILON)
        {
        //remove velocity around axis
        }

        Where lambda1 and lambda2 are the velocities around the two axis we don't want movement around, and checking against epsilon to avoid diving by zero. Shockingly I missed 50% of the cases where the velocities could be negative :doh: Two days I've spent wondering why the thing kept sliding off, two bloody days.

        if(FAbs(lambda1) > EPSILON)
        {
        //remove velocity around axis
        }
        if(FAbs(lambda2) > EPSILON)
        {
        //remove velocity around axis
        }

        Still, it's not all bad. In my quest to find the problem I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect. Now all that's left to do is tidy up the huge mess of code I've made.

        My current favourite word is: Smooth!

        -SK Genius

        W Offline
        W Offline
        wout de zeeuw
        wrote on last edited by
        #3

        I spotted that one in a second :laugh: (but I have a trained eye in this field). Why not remove velocity if smaller or equal to epsilon? Does it make sense if a value other than zero remains?

        Wout

        A 1 Reply Last reply
        0
        • W wout de zeeuw

          I spotted that one in a second :laugh: (but I have a trained eye in this field). Why not remove velocity if smaller or equal to epsilon? Does it make sense if a value other than zero remains?

          Wout

          A Offline
          A Offline
          Anthony Mushrow
          wrote on last edited by
          #4

          Well it's easy for you to spot it here, there isn't any other code to distract you! It's a royal PITA to find the causes of problems in this thing, you can see the problem on the screen but finding what is actually causing it is an entirely different matter. Still, it was because I was dividing by the values shortly after and you know what happens when you divide by zero. I actually trimmed back a lot of the code that was there, and as it happens I don't even need those checks any more. ;P

          My current favourite word is: Smooth!

          -SK Genius

          1 Reply Last reply
          0
          • D DaveAuld

            Maybe that is one reason why when testing always pick the upper and lower bounds for the data type in question, helps quickly find things like this! I was on a Factory Acceptance Test for a oil platform controls and shutdown system a few years back, the lead engineer on the project thought i was taking the pi$$ when i asked him to start pumping in random extreme values. Comments like, 'Operator would do that would they?', and they got back comments like 'Wouldn't they?[in a sarcastic tone]' and 'What about typo errors when entering values under pressure?'

            Dave Don't forget to rate messages!
            Find Me On: Web|Facebook|Twitter|LinkedIn
            Waving? dave.m.auld[at]googlewave.com

            T Offline
            T Offline
            The Manoj Kumar
            wrote on last edited by
            #5

            daveauld wrote:

            Maybe that is one reason why when testing always pick the upper and lower bounds for the data type in question, helps quickly find things like this!

            That's why when we write data oriented tests, we write Boundary Value test cases first (known as Boundary Value Analysis in testing).

            Regards,
            Manoj Kumar


            Blog:ManojKumar.me | Twitter:TheManojKumar | Facebook:TheManojKumar
            "No me, no life; Know me, know life."

            1 Reply Last reply
            0
            • A Anthony Mushrow

              I've spent the last couple of days working on some physics simulation for a car but I was having problems with stability, the car would kind of slide away very slowly and handling was, to put it lightly 'poor' The problem I found, was to do with the removal of angular velocity from the wheels (excluding the velocity around the axle). The code in question was this:

              if(lambda1 > EPSILON)
              {
              //remove velocity around axis
              }
              if(lambda2 > EPSILON)
              {
              //remove velocity around axis
              }

              Where lambda1 and lambda2 are the velocities around the two axis we don't want movement around, and checking against epsilon to avoid diving by zero. Shockingly I missed 50% of the cases where the velocities could be negative :doh: Two days I've spent wondering why the thing kept sliding off, two bloody days.

              if(FAbs(lambda1) > EPSILON)
              {
              //remove velocity around axis
              }
              if(FAbs(lambda2) > EPSILON)
              {
              //remove velocity around axis
              }

              Still, it's not all bad. In my quest to find the problem I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect. Now all that's left to do is tidy up the huge mess of code I've made.

              My current favourite word is: Smooth!

              -SK Genius

              C Offline
              C Offline
              Chris Maunder
              wrote on last edited by
              #6

              SK Genius wrote:

              I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect

              You mean: is a little stiff at first, with a bad rattle at the driver's rear wheel you can never find, then gradually the front shocks fade leaving the front end crazy floaty while the entire rear end sags like a granny's wotsit? I'll admit, I may have had a different experience with rebuilding suspension than you...

              cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

              1 Reply Last reply
              0
              • D DaveAuld

                Maybe that is one reason why when testing always pick the upper and lower bounds for the data type in question, helps quickly find things like this! I was on a Factory Acceptance Test for a oil platform controls and shutdown system a few years back, the lead engineer on the project thought i was taking the pi$$ when i asked him to start pumping in random extreme values. Comments like, 'Operator would do that would they?', and they got back comments like 'Wouldn't they?[in a sarcastic tone]' and 'What about typo errors when entering values under pressure?'

                Dave Don't forget to rate messages!
                Find Me On: Web|Facebook|Twitter|LinkedIn
                Waving? dave.m.auld[at]googlewave.com

                Q Offline
                Q Offline
                QuiJohn
                wrote on last edited by
                #7

                daveauld wrote:

                I was on a Factory Acceptance Test for a oil platform controls and shutdown system a few years back, the lead engineer on the project thought i was taking the pi$$ when i asked him to start pumping in random extreme values. Comments like, 'Operator would do that would they?', and they got back comments like 'Wouldn't they?[in a sarcastic tone]' and 'What about typo errors when entering values under pressure?'

                Umm, this wouldn't have been a contract for BP, would it?


                He said, "Boy I'm just old and lonely, But thank you for your concern, Here's wishing you a Happy New Year." I wished him one back in return.

                1 Reply Last reply
                0
                • A Anthony Mushrow

                  I've spent the last couple of days working on some physics simulation for a car but I was having problems with stability, the car would kind of slide away very slowly and handling was, to put it lightly 'poor' The problem I found, was to do with the removal of angular velocity from the wheels (excluding the velocity around the axle). The code in question was this:

                  if(lambda1 > EPSILON)
                  {
                  //remove velocity around axis
                  }
                  if(lambda2 > EPSILON)
                  {
                  //remove velocity around axis
                  }

                  Where lambda1 and lambda2 are the velocities around the two axis we don't want movement around, and checking against epsilon to avoid diving by zero. Shockingly I missed 50% of the cases where the velocities could be negative :doh: Two days I've spent wondering why the thing kept sliding off, two bloody days.

                  if(FAbs(lambda1) > EPSILON)
                  {
                  //remove velocity around axis
                  }
                  if(FAbs(lambda2) > EPSILON)
                  {
                  //remove velocity around axis
                  }

                  Still, it's not all bad. In my quest to find the problem I did end up setting up the suspension. Which, to my amazement works exactly like you'd expect. Now all that's left to do is tidy up the huge mess of code I've made.

                  My current favourite word is: Smooth!

                  -SK Genius

                  J Offline
                  J Offline
                  jayart
                  wrote on last edited by
                  #8

                  Wow this looks like an interesting project!

                  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