Get expression value

Asked

Viewed 66 times

0

In my javascript code I use this expression to make a calculation to get value of a graph with the mouse position (Posy). 460 is the position of my axis, and the maximum and minimum of the graph values of the y axis.

value =  ((460 - posY) * (maxtemp-txtmintemp)/(460-60)+txtmintemp);

From this expression I wanted to get the Y position, and I have the value, as for example this:

10.30 =  ((460 - posY) * (maxtemp-txtmintemp)/(460-60)+txtmintemp);

How can I calculate this expression, isolating Posy, which is the value I want to get.

  • What are the values of maxtemp and txtmintemp?

  • These are the minimum and maximum values of my y-axis. In this case the minimum is 2 and the max is 96.

  • Using this, I think to arrive at the value I want. http://es.solvemymath.com/calculated/algebra/resolver_ecuaciones.php

  • And this what do you want? m and maxTemp, n and txtMinTemp and x and the value.

1 answer

1


This is an Algebra exercise. By changing positions you can isolate Posy. This is how:

posY = - ((((10.30 - txtmintemp) * (460 - 60)) / (maxtemp - txtmintemp)) - 460);

Testing:

var maxtemp = 96;
var txtmintemp = 2;
var posY = -((((10.30 - txtmintemp) * (460 - 60)) / (maxtemp - txtmintemp)) - 460);
alert('posY dá: ' + posY);
var original = ((460 - posY) * (maxtemp - txtmintemp) / (460 - 60) + txtmintemp);
original = Math.round(original * 100) / 100
alert('verificação: ' + (10.30 == original));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.