> On Jan 24, 2017, at 10:45 AM, Eric E. Dolecki <[email protected]> wrote:
>
> So I am looking for a number between 100 and 200 which ends up being
> between 1.0 and 3.0.
Are you talking about linear interpolation? That would be
Set up the constants, as given in your email:
let dist0 = 100, dist1 = 200
let scale0 = 1.0, scale1 = 3.0
Then given `dist` you get the matching `scale`:
let scale = (dist - dist0) / (dist1 - dist0) * (scale1 - scale0) +
scale0
Make sure everything’s converted to double if necessary. If the dist values end
up typed as integers in the calculation, you’ll get hella roundoff error!
—Jens
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]