Jump to content
  • Advertisement
Sign in to follow this  
hyn

Help with weight distribution math

This topic is 4841 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

Hi, I'd like some help with a programming problem. Basically I want to have x rectangular objects on a fixed size screen (1280x1024 for example). The size of each object is determined in relation with _every_ object's variable attribute y. y can range from 1 to infinite. I'd want x to be > 1 and < 300 or so, due to performance issues. Example: there are 8 objects with the y value: 1, 2, 1, 3, 4, 4, 4, 3 The 4s are the biggest but I want them to account for the fact that there are three 4s, thus decreasing the size of the 4s. If there was only one 4, it would be bigger than a 4 in a series of 4s. If there are only 2 objects, they would occupy a good portion of the screen--If there are 300, they would still occupy the same space theoretically. So I think there is a constant z which determines the maximum size-points (weight), so that I don't get oversized objects. I can't find the proper term for it but I want the size (when graphed) line to be a straight one and not curved. So for example if object1 is 40 and object2 is 30, I want that size relation to be maintained. I could explain it farly well (I hope) but I don't have a clue how to come up with the math. Thanks for your help!

Share this post


Link to post
Share on other sites
Advertisement
Any help, please?
Let me know if there is something I should make clear.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I smell homework project!

Share this post


Link to post
Share on other sites
I think it's not homework. If it would be homework, it would be clear and would be already solved [grin]
Seriously, I readed it 2 times and I don't have a slightest idea of what OP want. I'm is serious, no offense, but it was one of the least readable posts in the history of this forum I think.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just calculate what fraction of the total each number is, then use that to figure out how big the object should be. So for 1, 2, 1, 3, 4, 4, 4, 3: the total is 22. The number 1 is 1/22 of that, 2 is 2/22, 4 is 4/22. You can get a size by multiplying that fraction by the total width you want all the objects together to be.

Share this post


Link to post
Share on other sites
Getting the proportions is the easy bit :) The tricky bit will be putting the rectangles on the screen. Then you have a packing problem.


-Josh

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!