I’m trying to come up with an algorithm to calculate the balancing point for a pack of materials any ideas?
All pieces will be flush at one end.
All pieces have the same weight per foot ratio.
I have a list of lengths and quantities
Originally I thought I could calculate the point where an equal amount of weight is on each side. This would be relatively easy to calculate using a loop.
Considering leveraging though the tipping point might not be at the point where an equal amount of weight is on each side.
I didn’t check your link, but this code should work:
totalWeight = 0
netMoment = 0
for i as integer = 0 to ubound(itemLength)
totalWeight = totalWeight + itemLength(i)* weightPerLength(i)
netMoment = netMoment + itemLength(i)^2* weightPerLength(i)
balancePt = 0.5 * netMoment/totalWeight
Add up all the lengths (weight doesn’t matter as all have the same weight per foot)
Divide the total by 2 * number of pieces
Eg two pieces of 4 and 5 foot = 9 ->. Divided by 2*2 -> 2.25
Three pieces of 3, 4, and 5 feet = 12 -> divide by 2*3 -> 2
Three pieces of 5, 5, and 20 feet = 30 -> divide by 2*3 -> 5 (with the long one at the bottom of course)
That is the approach I took at first but it is incorrect, due to the laws of physics. That method finds the point that has an equal amount of weight on each side.
Can you give an example where it would not be correct? At the moment I fail to see the problem.
Lets for example take my last numbers: 5,5,20
For simplicity the weight is 1
According to Robert:
TotalWeight = 30
NetMoment = 450
BalancePoint = 7.5 which seems wrong to me
Use the example below. It returns 45. Using your method would return 36.
The problem with your methods is that is calculates the point where and equal amount of weight is on each side. It does not consider the effects of leverage.
dim length(),Qty() as Double
Function BalancePt(Length() as Double, Qty() as Double) As Double
dim totalweight,netmoment as Double = 0
for i as Integer = 0 to min(Length.Ubound,Qty.Ubound)
totalWeight = totalWeight + (Length(i)*qty(i))
netMoment = netMoment + ((Length(i)^2) * qty(i))
Return 0.5 * netMoment/totalWeight
And what do you mean by “Considering leveraging though the tipping point might not be at the point where an equal amount of weight is on each side.”?
Ok in your example you have a total of 15 on each side of point at 5. So your thinking that it should balance right?
The problem is 10 of those feet from the 20’ sheet are farther from the balancing point than the two 5’ pieces on the other side.
Check out the link I posted above.
I think there is a piece of information missing: vertical or horizontal stacking?
I was stacking like this:
while I think you might be stacking vertically?
Consider a seesaw with the two children of equal weight. One sits on one side at the end. The other sits on the other side close to the centre. Both weigh the same, but the seesaw won’t be balanced.
As I suspected then. In which case the order of the items becomes important (as that determines the distance from the balance point), though the weight per foot is irrelevant as it is the same for all of them and is eliminated in the last line of code.
Roberts code does not take the order of items into account, it basically is
(Sum lenght^2 divided by Sum lenght) * 0.5
However the result needs to be different for each of the following arrangements
5 5 20
5 20 5
20 5 5
Robert’s code will get the same result for each of those arrangement.
It’s actually not that difficult to calculate if only the lenght differs but not their thickness and width. Is that the case?
In this case the thickness is nominal, .015 inch. So for discussion purposes the height is 0. Stacking is steel panels stacked up with all pieces flush at one end. Markus did you look at the link in my first post? It explains all this very well.