basic algebra help!

Started by
1 comment, last by slicer4ever 12 years, 7 months ago
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.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
Advertisement
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.

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

[quote name='slicer4ever' timestamp='1317967455' post='4869995']
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.

[/quote]

wow, you make it so simple, for some reason, i couldn't get it through my head to multiply the outside variable into the inside variable, and then subtract like normal, thanks alot mate=-).
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

This topic is closed to new replies.

Advertisement