Jump to content
  • Advertisement
Sign in to follow this  
slicer4ever

basic algebra help!

This topic is 2626 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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=-).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!