• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Math question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Math question


  • Subject: Re: Math question
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 24 Jan 2017 10:55:31 -0800

> On Jan 24, 2017, at 10:45 AM, Eric E. Dolecki <email@hidden> 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@hidden)

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:

This email sent to email@hidden


References: 
 >Math question (From: "Eric E. Dolecki" <email@hidden>)

  • Prev by Date: Re: Math question
  • Next by Date: Re: Math question
  • Previous by thread: Re: Math question
  • Next by thread: PDF to Word ( docx) Conversion
  • Index(es):
    • Date
    • Thread