Subject:
|
Re: Simple Maths Help Needed
|
Newsgroups:
|
lugnet.cad.dev
|
Date:
|
Sun, 5 Feb 2006 00:13:33 GMT
|
Viewed:
|
2314 times
|
| |
| |
In lugnet.cad.dev, Tore Eriksson wrote:
> > > This is very simple, I know, but I insist on doing it wrong every time!
> > > So, I have to humble myself and ask for the formula for this quite basic
> > > implementation.
> >
> > I think what you want is:
> >
> > value = start_value + ((end_value - start_value) * (Progress - from) / (to -
> > from))
> >
> > HTH
> >
> > ROSCO
>
> Oh, how close I was, and yet... Thanks a lot, Rosco!
>
> /Tore#
There is another way ;)
(Start_value*(to-Progress)+End_value*(Progress-from))/(to-from)
Is nice and symmetric and more numerically stable.
Tim
|
|
Message has 1 Reply: | | Re: Simple Maths Help Needed
|
| (...) Rule #1: Never fix anything that's not broken! :) I need to make an if statement to take care of the exception where 'to' equals 'from', to avoid a division by zero crash anyway. Who knows what users can bring up... /Tore (19 years ago, 5-Feb-06, to lugnet.cad.dev)
|
Message is in Reply To:
5 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|