123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|551|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> math question...

Tue, 15 Jan 2008, 12:21
spinal
I have a progress bar in my video player and want to add skipping, the thing is I keep forgetting equations I used to know many years ago. Currently I calculate the position of the bar by the following -

x = (250/(float)vidhead.framecount)*play_on;

250 is the width of the bar, vidhead.framecount is the max number of frames, play on, is the current frame.

I need to do the opposite of this and fin what play_on would be if I have x. Anyone help?

-=-=-
Check out my excellent homepage!
Tue, 15 Jan 2008, 12:33
Jayenkai
Switch from doing the math one way to the other.

Pos1=(Total1/Total2)*Pos2
so
Pos2=(Total2/Total1)*Pos1
which means
play_on=(vidhead.framecount/250)*x


-=-=-
''Load, Next List!''
Tue, 15 Jan 2008, 12:39
spinal
Thanks Jay, how much credit in the play you want for this?

-=-=-
Check out my excellent homepage!
Tue, 15 Jan 2008, 12:45
Jayenkai
Oh, additionally, though..
I'm not too sure how good the DS's floating point maths are, so you might be better off doing things the opposite way round. (ie, it'd be slightly more accurate with big numbers than with little ones..)

in which case you'd be better off doing the multiplier first, and THEN divide.

x=(250*play_on)/vidhead.framecount
and
play_on=(vidhead.framecount*x)/250

-=-=-
''Load, Next List!''
Tue, 15 Jan 2008, 14:05
spinal
Thanks Jay, good idea. Also I finally got it capped to 15fps, not sure why it works though.

|edit| yes I do, silly me. I was confusing how fast the timer is ticking. |edit|

-=-=-
Check out my excellent homepage!