Evenly distributing weight among points

305 views Asked by At

I'm working on an application for BeamNG where users enter the center of gravity and total weight of their physics structure, then the program will load in all the XYZ positions of the structure and weight each point individually in KG.

Does anybody have the math behind this? The program would load each point into an XYZ coordinate and would have the coordinate count, and it would also have the center of gravity in an XYZ coordinate.

2

There are 2 answers

0
Spektre On

I would try to do it like this:

  1. compute CoG.x
  2. compare it with predefined CoG0.x
    • if not zero then shift some weight from left to right
    • or reverse (dependent on CoG0.x-Cog.x sign)
    • scale weight amount by the CoG0.x-Cog.x magnitude
    • and by distance of source and destination mass point position from CoG0
    • this can also be done by uniformly changing all points not just two
    • just divide points by relative position to CoG0 to left and right ...
  3. loop and increase accuracy up to some treshold/recursion layer...
  4. process y,z coordinates in the same way
  5. when done loop the whole thing few times to iteratively get close to result
    • because approximating each axis can change the other ones
    • to avoid that you should choose points close to x,y,z axises
0
Jordi Cruzado On

Supose each point XYZ is Pi = (xi,yi,zi) and the weight of each point is Wi, you can calculate the CoG = (xc, yc, zc) in this way:

xc = ( W1*x1 + W2*x2 + ... + Wn*xn ) / ( W1 + W2 + .... + Wn )

yc = ( W1*y1 + W2*y2 + ... + Wn*yn ) / ( W1 + W2 + .... + Wn )

zc = ( W1*z1 + W2*z2 + ... + Wn*zn ) / ( W1 + W2 + .... + Wn )