• Advertisement
Sign in to follow this  

problems solving for time

This topic is 3552 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to write a function that takes a velocity and an acceleration and will return how much time it takes to travel x distance. First i wrote it with only velocity and it was simple: D = Vt+ 1/2At² D = Vt //acceleration is 0 D/V = t TargetImpactTimer = Distance/Velocity;
float TimeTaken(Distance,Velocity,Acceleration)
{
return Distance/Velocity;
}

then i wrote it zeroing out the velocity D = Vt+ 1/2At² D = 1/2At² //Velocity is zero 2D = At² 2D/A = t² sqrt(2D/a) = t TargetImpactTimer = sqrt(2*Distance/AccelerationLength);

float TimeTaken(Distance,Velocity,Acceleration)
{
return sqrt(2*Distance/AccelerationLength);
}

and this works fine too. But I cant seem to combine the two to make a function that would use them both.

Share this post


Link to post
Share on other sites
Advertisement
Don't set anything equal to zero
Just solve for t.

t = (sqrt(v^2+2*a*d)-v)/a

Share this post


Link to post
Share on other sites
omg spent forever checking my math when I was returning the wrong type... guh... anyways thank you for the help phil126. Ratings up if you care about that sorta stuff =)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement