c# - How can I calculate individual point masses? -


I am working on the C # 2D soft body physics engine and I need to give the collectors of the object: The total mass for the list object, and the center of the mass.

The center of mass is given as:

alt text

Where,

  r = center of mass m = total mass mj = peak jr j the mass = peak j's position  

I need an algorithm that is available for every M.J. Can be given R, M, and RJ.

Edit: I just want to make it clear that I know that there is an endless set of solutions. I am searching for a quick algorithm that finds a set of MJ (As if they are close to each MJ = M / [corner number] and where "enough" is defined as some small temporary point boundary).

In addition, each object will contain approximately 5 to 35 digits.

You can calculate the chief minister of an equally dense polygon as follows: 0 .. N-1 to N, and cyclically treat them, so that the top n is wrapped for the top.

  total_area = sum [i = 0 ... n -1 ] (X [P] [i] P (I + 1)) / 2) CM = equal [i = 0 .. N-1] ((P [I] + P [I + 1] * X (P [ Ii], p [i + 1]) / 6) / total_array where x (p, q) = px * qy - qx * ​​py [basically, a 2d cross product]   

If the polygon is convex, then the chief minister will be inside the polygon, so that you can begin to paste the area in the triangle with a chief like a pie in the hub, without changing the Chief Minister. With the third, we should be able to have each vertical weight of the triangle - however, it will still leave a third of the total mass on the whole polygon's CM. , Mass transfer from the scaling of 3/2, you must divide the mass of each triangle between two "outer" corner. As a result,

  area [i] = x ((p [i] -cm), (p [i + 1] -cm) / 2 (this is the area of ​​cm and corner in And i + 1) mass [i] = (total_mas / total_rrea) * (area [i-1] + area [i]) / 2  

between the notes that triangle such that Mass transfers are profoundly "unfriendly" - if nothing else, if it is really treated, then the moment of inertia will be something terrible. However, if you need to distribute the mass between the corners (Such as for any type of cheese explosion), and you do not want to disrupt the chief minister in doing so, then this should do the trick.

Finally, a couple of warning:

  • If you do not use the actual Chief Minister for this, then it will not do the right thing
  • It is dangerous to use it on concave objects; You risk the ending with the negative public; / Li>

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -