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.

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 on other sites
Let me know if there is something I should make clear.

Share on other sites
I smell homework project!

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 on other sites
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 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

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 9
• Forum Statistics

• Total Topics
633338
• Total Posts
3011417
• Who's Online (See full list)

There are no registered users currently online

×