Reputation: 31
I have a c++ program which the user will click on two points on the screen and I have to create a logarithym scale from that.. Like:
10 100 1000 10000
given that my first point is at 10 supossed pixel 5 and 10000 is given at pixel 200
So how do I calculate the equation that would make my mouse show the log value when it points to the screen.
Thanks.
Upvotes: 3
Views: 3392
Reputation: 47513
All you need is the log
function. Let's first assume no offset. If you are given a value of x
on the X-axis, you can get it's log value (e.g. in base 10) by:
log(x) / log(10)
If you want x
to count from a certain offset (say x0
), you should adjust x
:
log(x - x0) / log(10)
If you want the resulting point to be offset at a point (say lx0
), well just do it:
log(x - x0) / log(10) + lx0
Upvotes: 2