# problems solving for time

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

## 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 on other sites
Don't set anything equal to zero
Just solve for t.

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

##### 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 =)

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 12
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633314
• Total Posts
3011327
• ### Who's Online (See full list)

There are no registered users currently online

×