• Create Account

# Lxu

Member Since 07 Oct 2011
Offline Last Active Mar 03 2013 08:36 AM

### #4870545basic algebra help!

Posted by on 08 October 2011 - 11:54 AM

Lets see if i can help.

6.8 = ((r+1)*2*2 - (r+1)*0.3*2)/2 = (r+1)*2 - (r+1)*0.3 = ?
so you need to work on the individual multiplications first
(r+1)*2 = 2*r + 1*2 = 2r + 2
and
(r+1)*0.3 = 0.3r + 0.3
and then subtract them
(2r+2) - (0.3r + 0.3) = 1.7r + 1.7
with the other side together
1.7r + 1.7 = 6.8/2 => 1.7r = 3.4 - 1.7 => 1.7r = 1.7 => r= 1

edit:
here (r+1)*2 - (r+1)*0.3 you can do this way too:
(r+1)* ( 2 - 0.3 ) = 1.7(r+1)
a more direct choice.

to programming this you need to isolate the r variable and come with a straight formula i think.

(r+s)*2*w - (r+s)*0.3*w = F(r,s,w)
w*( (r+s)*2 - (r+s)*0.3 ) = F(r,s,w)
(r+s)*2 - (r+s)*0.3 = F(r,s,w) / w
2r + 2s - 0.3r - 0.3s = F(r,s,w) / w
1.7r + 1.7s = F(r,s,w) / w
1.7r = F(r,s,w) / w - 1.7s
r = ( F(r,s,w) / w - 1.7s ) / 1.7

lets test this so: F(r,s,w) = 6.8, w = 2, s = 1

r = ( 6.8 / 2 - 1.7*1 ) / 1.7
r = 1

hello everyone, in a game i'm writing, i want the object's to scale with the viewport, so i know how large the object's take up in window space with the following formula:
F(r,s,w) = (r+s)*2*w - (r+s)*0.3*w; <-- for width
F(r,s,h) = (r+s)*2*h + (w>1?r+s:0.0f); <-- for height(note this is an example, and relies on knowing the width, which is why the height code relies on w/e the width is, but i figured i could reduce it down to this simple problem for getting help.)

anyway, i know i've got to simple work backwards, basically, the only variable i need to calculate is whatever r has to be for the function to equal my target size.
for simplicity, all i want to achieve at the moment is reversing the answer without knowing r.
so i did:
F(1,1,2) = (1+1)*2*2 - (1+1)*0.3*2 = 2*2*2 - 2*0.3*2 = 8 - 1.2 = 6.8
and to reverse i did:
6.8 = ((r+1)*2*2 - (r+1)*0.3*2)/2 = (r+1)*2 - (r+1)*0.3 = ? this is where i get tripped up, i can't figure out how to divide out the 0.3 on both sides or the 2 on both sides, since r+1 has been reduced to a subtraction problem with multiplication still in it.

as for height:
F(1,1,2) = (1+1)*2*2 + (1+1) = 2*2*2 + 2 = 10
i get the same problem, dividing on both sides of the problem:
F(r,1,2) = ((r+1)*2*2)/2 + (r+1)/2 = ??

thanks for the mathmatical help all.

PARTNERS