1

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.

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
aaro4130
  • 115
  • 1
  • 9
  • Do you mean the user enters CoG of structure, Weight of structure, XYZ and the program will just figure out the weights of the points? – Rollen Mar 19 '15 at 18:31
  • User enters CoG and weight and it loads points from a file, I can handle that part but don't know the math. – aaro4130 Mar 19 '15 at 18:33
  • Math to do what exactly....? your question isn't entirely clear – Rollen Mar 19 '15 at 18:34
  • I've never been good with words lol, sorry. – aaro4130 Mar 19 '15 at 18:36
  • Calculate the mass of each point to make the CoG the CoG. Each point has its own weight but that means the CoG will by default be at the area with the most point density. – aaro4130 Mar 19 '15 at 18:36
  • You can use the first formula here http://en.wikipedia.org/wiki/Center_of_mass#A_system_of_particles to form a system of 3 equations in N unknowns (N being number of points). That's an underdetermined system so there are infinitely many possibilities. There are a number of ways to solve those types of equations such as using the least squares or gaussian elimination (check wiki on this). – Rollen Mar 19 '15 at 18:40

2 Answers2

1

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 )
Jordi Cruzado
  • 875
  • 6
  • 13
0

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
Spektre
  • 49,595
  • 11
  • 110
  • 380