[Gambas-user] miles per hour to pixels per frame (general unit conversion function)

Caveat Gambas at ...1950...
Sat Aug 20 09:57:34 CEST 2011


Seems ok to me...

5280 feet in a mile, 128 pixels in a foot 
= 128*5280 
= 675840 pixels in a mile

At 20 MPH you'd cover 
20*675840 pixels 
= 13516800 pixels

In a whole hour you'd cover 13516800 pixels but each frame only lasts
1/30th second, there's 60 seconds in a minute and 60 minutes in an hour
so in one frame (lasting 1/108000th of an hour) you'd cover:
13516800 / (30 * 60 * 60) pixels
= 13516800 / 108000 pixels 
= 125.155556 pixels

Or put another way:
20 * 675840 / 108000 
= 125.155556
= MPH2PPF(20)

Scary corollary:  at 120 km/hr you do 2km / minute
= 2000 metres/minute
= 2000/60 metres per second
= 33 metres per second!

If you take just 1/2 a second to react to a problem, you'll already be
17 metres closer to it, and if you take your eyes off the road just for
a second to answer a text or change CDs... :-O

Regards,
Caveat

On Sat, 2011-08-20 at 03:17 -0400, Kevin Fishburne wrote:
> I came up with this equation, which I think is correct:
> 
> Public Function MPH2PPF(MPH As Single) As Single
> 
>    ' Convert miles per hour to pixels per frame.
> 
>    ' 1 mile = 675840 pixels.
>    ' 1 hour = 108000 frames.
> 
>    Return MPH * 675840 / 108000
> 
> End
> 
> The frame rate is 30 FPS, and 128 pixels = one foot. Can anyone verify 
> that this is correct?
> 






More information about the User mailing list