Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 1st Apr 2011 06:47
I have 2 numbers like say 10 and 5. how can i find the ratio between the 2

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 1st Apr 2011 07:13
ratio#=10.0/5.0

Or do you mean like input 5 and 10, and get out "5:10" or "1:2"?

pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 1st Apr 2011 07:33
the "1:2" one. I need it for screen ratios. so if i got 800 and 600. thats obviously a 4 to 3 ratio, but not everyone will have that screen size. So I'll need maths for the different sizes.

Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 1st Apr 2011 08:11
You might just want to look into the "PERFORM CHECKLIST FOR DISPLAY MODES" command.

pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 1st Apr 2011 19:11
I got it figured out. I was trying to take the screen width and height and get a correct ratio from them. Instead I ended up using vectors to the FOV to get the ratio. Thank you though.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Apr 2011 23:11
You take the two dimensions as a fraction and simplify it.

800:600
(divided by 200)
4:3

1920:1080
(divided by 120)
16:9

Find the greatest common denominator and divide.

The Internet: Where men are men, women are men, and children are federal agents
pictionaryjr
17
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 1st Apr 2011 23:25 Edited at: 1st Apr 2011 23:29
how would you do that with code. the computer can't just magically know what the GCD is

These are the functions I made from it:


Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 1st Apr 2011 23:33
Well... you can make an algorithm to store all prime factors of the two numbers, remove all the common numbers, and then multiply each array back together to get your ratio.

But seriously... if you are doing this for screen sizes, use something like this:


IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Apr 2011 13:43
You are never going to get perfect ratios 100% of the time from modern displays (my current laptop has a display of 1366:768, with a gcd of 2).

That said, there's a GCD function built into one of my plug-ins that you could use if you want to go down that route.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Apr 2011 02:08
I like the 16:9 ratio of screens, but I think those even wider aspect screens (like the one Ian apparently has) is just too wide for a computer monitor.

The Internet: Where men are men, women are men, and children are federal agents

Login to post a reply

Server time is: 2026-07-11 14:56:58
Your offset time is: 2026-07-11 14:56:58