Jump to content

NumericUpDown - conversão


marcos paulo
 Share

Recommended Posts

Isso é um pouco de matemática.

Considerando a forma geral f(x)=mx+b, temos que f(0)=0 e f(100)=255.

Uma vez que b=f(0) e f(0)=0, então b=0.

O declive da recta é dado por m=(y2-y1)/(x2-x1), portanto m=(255-0)/(100-0) <=> m=2,55.

Concluímos que f(x)=2,55*x.

Ou seja, quando o NumericUpDown tem o valor x, deverás enviar para a porta o valor 2,55*x.

Entendeste o meu raciocínio?

P.S.: neste caso podíamos saltar alguns passos e fazer a fórmula directamente, mas quando as escalas são diferentes do que 0-A para 0-B, convém saber fazer isto. 😉

Edited by thoga31

Knowledge is free!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.