## math question: Scale Conversions

### math question: Scale Conversions

This is less of a graphics question per se and more of a general math
question. Suppose you have an interval [a,b] and a point p in this interval.
Additionally, you have another interval [c,d] and a point p' in this
interval. Given that a, b, c, d, p, and p' all represent real numbers, what
is the general formula for deriving p' from p?

The classic example I happened to think of is the Celsius to Fahrenheit
conversion, in which [a,b] is [0,100] and [c,d] is [32,212]. Suppose that p
= 50. Then p' = (9/5)*p + 32 = 122.

This general strategy doesn't seem to work for an arbitrary scale, though.
Following the C-to-F guidelines, I couldn't seem to derive a formula for
converting, say, [1,4] to [3,7].

Any hints?

### math question: Scale Conversions

It's so ironic how being frustrated enough to ask a question that's been
plaguing you often puts you on the track to the right answer. For anyone
else who cares, the formula is p' = [ (p-a)/(b-a) ] * (d-c) + c. The reverse
conversion is p = [ (p'-c)/(d-c) ] * (b-a) + a.

- Marc

Quote:> This is less of a graphics question per se and more of a general math
> question. Suppose you have an interval [a,b] and a point p in this
interval.
> Additionally, you have another interval [c,d] and a point p' in this
> interval. Given that a, b, c, d, p, and p' all represent real numbers,
what
> is the general formula for deriving p' from p?

> The classic example I happened to think of is the Celsius to Fahrenheit
> conversion, in which [a,b] is [0,100] and [c,d] is [32,212]. Suppose that
p
> = 50. Then p' = (9/5)*p + 32 = 122.

> This general strategy doesn't seem to work for an arbitrary scale, though.
> Following the C-to-F guidelines, I couldn't seem to derive a formula for
> converting, say, [1,4] to [3,7].

> Any hints?

### math question: Scale Conversions

Quote:> This is less of a graphics question per se and more of a general math
> question. Suppose you have an interval [a,b] and a point p in this
interval.
> Additionally, you have another interval [c,d] and a point p' in this
> interval. Given that a, b, c, d, p, and p' all represent real numbers,
what
> is the general formula for deriving p' from p?

> The classic example I happened to think of is the Celsius to Fahrenheit
> conversion, in which [a,b] is [0,100] and [c,d] is [32,212]. Suppose that
p
> = 50. Then p' = (9/5)*p + 32 = 122.

> This general strategy doesn't seem to work for an arbitrary scale, though.
> Following the C-to-F guidelines, I couldn't seem to derive a formula for
> converting, say, [1,4] to [3,7].

You can use Linear interpolation for this:

'***
Private Function Linear(ByVal inValA As Double, _
ByVal inValB As Double, ByVal inPos As Double) As Double
Linear = ((inValB - inValA) * inPos) + inValA
End Function
'***

<pseudocode>
p' = Linear(32, 212, (50 - 0) / (100 - 0))
</pseudocode>

Obviously you'd get rid of the (-0)'s in this for this, but this is generic
for any range, i.e going the other way:

<pseudocode>
p = Linear(0, 100, (p' - 32) / (212 - 32))
</pseudocode>

You just need a position within a range and linear interpolation will do the
rest.
Hope this helps,

Mike

- Microsoft Visual Basic MVP -

WWW: Http://www.mvps.org/EDais/

### math question: Scale Conversions

top posting repaired...

> > ...Suppose you have an interval [a,b] and a point p in this interval.
> > Additionally, you have another interval [c,d] and a point p' in this
> > interval. Given that a, b, c, d, p, and p' all represent real numbers,
> > what is the general formula for deriving p' from p?

> > The classic example I happened to think of is the Celsius to Fahrenheit
> > conversion, in which [a,b] is [0,100] and [c,d] is [32,212]. Suppose that
> > p = 50. Then p' = (9/5)*p + 32 = 122.

....
> It's so ironic how being frustrated enough to ask a question that's been
> plaguing you often puts you on the track to the right answer. For anyone
> else who cares, the formula is

> p' = [ (p-a)/(b-a) ] * (d-c) + c.

> The reverse conversion is p = [ (p'-c)/(d-c) ] * (b-a) + a.

Yes...but in relationship to your conversion formula, the formula for a
straight line between two points is y = Mx + B where M is the slope and
B is the intercept.  The general solution is (in your interval
nomenclature and uppercase M and B to keep the "bee's" straight)

M = (d-c)/(b-a), and B = c - Ma

so another equivalent expression is p' = pM + B which may be simpler to
carry around....

I'm using PS 4.01 on a Mac PowerPC with OS 8.1, but the problem
was occurring with OS 8.0 as well.

When I'm creating text at small sizes, I usually create the text at 80
pts and then use the numeric scaling to reduce it to, say, 12 points. I
often get a truncation effect on the scaled down text, as if the top,
bottom, left or right side is cut off. It doesn't happen everytime but
it happens very frequently.

Any ideas? Thanks.

Tim Ware
HyperArts
www.hyperarts.com