Casey Clayton wrote:So what I have is a track, which has a set length in feet and a set speed which is feet per second... Now I need to take say a track length of 21 feet with a speed of 1ft/s and figure out how long the animation should last...
Paul Clapham wrote:
Casey Clayton wrote:So what I have is a track, which has a set length in feet and a set speed which is feet per second... Now I need to take say a track length of 21 feet with a speed of 1ft/s and figure out how long the animation should last...
You want an answer in seconds, so you're going to have to multiply feet by seconds/feet (yes, the dimensions work just like their values do in arithmetic). So suppose your track length is 18 feet and the speed is 2 feet/second. To get seconds/feet you take the reciprocal, so that's 0.5 seconds/feet. Multiplying that by 18 feet gives you 9 seconds for the length of the animation.
Now, that's assuming you want your animation to take the same amount of time that the box actually takes to move along the conveyor. You might want to speed it up, because having it take 9 seconds to cross a small computer monitor might not produce the right effect. However I'd leave that part aside for now and just work on simulating the box's travel in real time. Inserting a speedup (or slowdown) factor could be done later without too much difficulty.
Casey Clayton wrote:...since that the track will always be 1200px on the screen but the actual length in feet will vary from track to track. So say if it is a 40 foot track and the box is 12.5 feet in then how many pixels do I place box at on the X Axis.
Casey Clayton wrote:See I have that basic calculation down but the problem occurs when the placing the boxes and then doing the calculation. I receive the boxes last known location in feet, which I need to convert to pixels to place it properly on the screen. This is the calculation I am having trouble with I guess, taking that data in feet and converting it to pixels since that the track will always be 1200px on the screen but the actual length in feet will vary from track to track. So say if it is a 40 foot track and the box is 12.5 feet in then how many pixels do I place box at on the X Axis.
There are only two hard things in computer science: cache invalidation, naming things, and offbyone errors
Create symphonies in seed and soil. For this tiny ad:
We need your help  Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanchserverfundraiser
