Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Solving for time in 1D Kinematics

  1. Oct 3, 2011 #1
    Short Version:

    It's been several years since I last practiced any mathematics or physics. I'm trying to get my mind as sharp as it was back then. I'm sure the solution is obvious, and just under my nose...

    I remember:

    P = P' + V't + (at^2)/2

    Where P is position, P' is initial position, V' is initial Velocity, a is acceleration, and t is time.

    Solve for t. All other variables are known.

    I feel so embarrassed I don't remember how to do this.

    Long Version (programmers may be interested):

    Before I joined the military I had a good hobby of computer programming, and did well with mathematics and physics. Now, my mental capacity is at an all time low, and I thought picking my hobby back up again would do me good. The past few weeks have been great! But then I hit a brick wall, and 2 days of Googling and still no answer is starting to affect my enthusiasm. It's not like me to sign up to a physics forum and create an account just to ask one question, but perhaps it's not so bad to call upon the help of charitable others if you're thankful.

    Anyway, my current project is simple, and nothing special. It's not meant to be. It'd not the product I expect to benefit from; it's the journey. So, it's really just a bouncing ball – I wanted to implement some collision detection ideas I've had. My main idea is instead of looking for collision by seeing if collidable objects are overlapping and correct them, calculate when they'll collide. Queue a collision event in a timeline using that time, and execute the collision reaction code once that time comes.

    This is my latest build that's a good example: http://selroth.draconity.org/Projects/Active/White Sands/Javascript/20110930/

    The vertical chart on the right is the timeline, and you can see the collision events crossing the cyan line at the moment the ball collides with the wall.

    However, it's actually flawed/not fully functional in that aspect yet, despite initial impressions. Because the time of collision is always changing when there's an acceleration, it's difficult for the program to move the timeline to the exact time it needs to be at. Currently, it takes the time simply by dividing the distance between the wall and the ball by the ball's velocity.

    I'm at a point where I need it to account for the ball's acceleration too – the event marks on the timeline shouldn't move around.

    (current version can be found here: http://selroth.draconity.org/Projects/Active/White Sands/Javascript/Current/ which has better comments and cleaner code if you want to look at the sourcecode yourself [Chromers can Shift+Ctrl+J, Firefoxers can FireBug, IE or Safari'ers can get a better browser =P] )

    Otherwise, this is the function I'm having trouble with:
    Code (Text):

        //Find the time of collision for either the top or bottom walls
        function findYCollision(){ return (yVel < 0) ? "top wall" : "bottom wall"; }   
        function findYCollisionTime(){
            var d = (findYCollision() == "top wall") ? yPos :  400 - yPos;
            var t = gameTime + (d / Math.abs(yVel));
            return (t > gameTime) ? t : gameTime;
        }
     
    I can't figure out how to rewrite t = ______ to where it accounts for acceleration (would be known as yAcc in this case)

    I am extremely grateful for any replies, and have marked this topic for email notifications! Thank you!
     
    Last edited: Oct 3, 2011
  2. jcsd
  3. Oct 3, 2011 #2
  4. Oct 6, 2011 #3

    Redbelly98

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper

    Welcome to Physics Forums :smile:
    Ah, and welcome (back) to the world of physics :biggrin:
     
  5. Oct 6, 2011 #4
    Thanks! :)
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook