Go to Post woo hoo! I rigged up brief Internet access using an old wornout robot battery. - Mark McLeod [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-02-2012, 17:38
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
Complex math equation

I was wondering if someone could help me figure out an equation for:

I want to scale a double (between 8-13) to be from 0 - 100.
So 8 will be 0, 9 will be 20, 13 will be 100, 12.5 will be 90 and so on.

I hope that makes sense and would appreciate if someone could help.

Thanks in advance!
Reply With Quote
  #2   Spotlight this post!  
Unread 25-02-2012, 17:42
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Complex math equation

Quote:
Originally Posted by neal View Post
I was wondering if someone could help me figure out an equation for:

I want to scale a double (between 8-13) to be from 0 - 100.
So 8 will be 0, 9 will be 20, 13 will be 100, 12.5 will be 90 and so on.

I hope that makes sense and would appreciate if someone could help.

Thanks in advance!

y = 20*x - 160


Reply With Quote
  #3   Spotlight this post!  
Unread 25-02-2012, 17:42
connor.worley's Avatar
connor.worley connor.worley is offline
Registered User
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2010
Location: Berkeley/San Diego
Posts: 601
connor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond repute
Re: Complex math equation

Well, you have a range of 5 and you want to scale that to a range of 100, so you'll need to multiply by 20. You want to start at 8 though, so you need to subtract 8 * 20.

output = 20*input - 160
__________________
Team 973 (2016-???)
Team 5499 (2015-2016)
Team 254 (2014-2015)

Team 1538 (2011-2014)
2014 Driver (25W 17L 1T)
日本語でOK
Reply With Quote
  #4   Spotlight this post!  
Unread 25-02-2012, 17:46
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
Re: Complex math equation

Thanks Ether and Connor!
Reply With Quote
  #5   Spotlight this post!  
Unread 25-02-2012, 19:33
Cal578 Cal578 is offline
Passionate FIRST-er, CD donor
AKA: Gerry
FRC #0578 (Red Raider Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2008
Location: Rochester, NY
Posts: 256
Cal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant futureCal578 has a brilliant future
Re: Complex math equation

You should know the general process for figuring this out, just in case your situation changes and you want a new formula.

You want:
y = m * x + b

and you want this to be true for x=8 -> y=0, and for x=13 -> y=100.

So, you have two equations to solve for two variables:
0 = m * 8 + b
100 = m * 13 + b

If you subtract the first equation from the second, the b terms will cancel out:
100 = m * (13 - 8)
100 = m * 5
20 = m

Substitute 20 into either of the equations (the first is easier):
0 = 20 * 8 + b
b = -160

I hope this is helpful. When I saw the thread title "Complex math equation", I thought we were going to discuss real and imaginary numbers. A math geek gets easily excited...
__________________
Cal
R3: Red Raider Robotics (FRC Team 578)
Fairport, NY, USA
www.FairportRobotics.org
2016 Finger Lakes Regional: Semifinalist on Alliance 7 (1128, 2010, 578)
2016 NYC Regional: Finalist on Alliance 3 (3419, 578, 3017), 4th seed team, Team Spirit Award
2015 Finger Lakes Regional: 8-3-0 in qualification, 7th seed, Quarterfinalist
2014 NY Tech Valley Regional: 8-4-0 in qualification, 13th seed, Semifinalist
2013 Finger Lakes Regional: 4-5-0 in qualification, 26th seed, Alliance 6, 1-2 in tournament
2012 Buckeye Regional: Gracious Professionalism Award, 7-3-0, 14th seed
2011 Finger Lakes Regional: Engineering Inspiration Award
Reply With Quote
  #6   Spotlight this post!  
Unread 25-02-2012, 20:04
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Complex math equation



Just use the two-point formula:

y = y1+(x-x1)/(x2-x1)*(y2-y1)

with x1=8, x2=13, y1=0, y2=100 this gives y = 20*(x-8)

or plot your data in Excel

8,0
9,20
12.5,90
13,100

to see the shape, and then

click on "add trendline" and select an appropriate model (linear in this case) to fit (and it will give you the equation)


Last edited by Ether : 25-02-2012 at 20:07.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi