# $1/r^2$ gravitational force of triangles in 2D

Suppose I have two triangles relatively close together (so they probably shouldn't really be treated as point masses). I want to calculate the gravitational force (and potentially torque?) generated between the two bodies in the 2D plane.

For spheres/circles you can just treat them as point masses and go from there, but can you do that for arbitrary triangles (or tetrahedrons in 3D)?

I know the answer is probably to do a spatial integral across both triangles, but it's been a long time since I knew how to do that :)

The end goal is to be able to compute the gravitational force between arbitrary polygons/polyhedra. I figured decomposing it in to triangles/tetrahedrons would be a good start.

...

UPDATE:

Okay, my multidimensional calculus is a bit rusty, but I think this is a promising direction:

Let: $$\vec{f} = (a - c) \mu_1 + (b - c) \upsilon_1 - (x - z) \mu_2 - (y-z) \upsilon_2 - (z - c)$$ be the separation vector between two points on either triangle,

where $a, b, c$ are the vertices of triangle 1, and $\mu_1, \upsilon_1$ are the barycentric coordinates (corresponding to $a$ and $b$) for the point on triangle 1. Likewise for $x, y, z$ and $\mu_2, \upsilon_2$ for triangle 2. Using the barycentric coordinates let's us form the spatial integral to arrive at an answer.

So the (linear, non-torque) force between them is proportional to:

$$\vec{F_G} = \displaystyle\int_0^1 \int_0^{1-v_2} \int_0^{1} \int_0^{1-v_1} \! \frac{f}{||{f}||^3} \, \mathrm{d} \mu_1 \mathrm{d} \upsilon_1 \mathrm{d} \mu_2 \mathrm{d} \upsilon_2$$

I think this admits a closed form solution, though I'm still wrestling with Mathematica. I'd really be surprised if this integral hasn't been done somewhere before, though.

-
Do you want to treat gravity in your 2D plane as a 1/r field or a 1/r^2 field? This always comes up in these questions. Provided you chose 1/r^2, your statement about the circle isn't even true. Finally, even with clear specification of the problem, such integrals are often mathematically very very difficult. I doubt the computation of the field from a single triangle would be anything close to simple. – Alan Rominger Apr 2 '12 at 18:07
Inverse square. Also, I'm assuming Newtonian Gravity (ignoring relativity and the like). Are you sure about circle? Not that wikipedia is the pinnacle of correctness, but it says "In this way it can be shown that an object with a spherically-symmetric distribution of mass exerts the same gravitational attraction on external bodies as if all the object's mass were concentrated at a point at its centre.(This is not generally true for non-spherically-symmetrical bodies.)" from this page: en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation. – Jay Lemmon Apr 2 '12 at 18:12
Convincing point, although I'm not fully convinced. I should have more prudently said your statement about the circle isn't necessarily true. My guess, however, is that their definition of "spherically symmetric" would not apply to a 2D circle in 3D space (otherwise "a pancake"). I also have several thought experiments that would probably disprove this. Approaching the pancake's edge within its plane gives increasing field at minimum of 1/r (field around a wire), so it's already shot there. Spherically symmetric would be like Jupiter where density is a function of radius alone. – Alan Rominger Apr 2 '12 at 18:23
@anna-v: yes, I know. But this is not three bodies. This is two bodies. And I'm not trying to find an analytical solution for their motion over time, I'm trying to find an analytical solution for their mutual attraction at a specific moment in time. (And actually, a numerical solution would be okay, too, if it could be robustly calculated). – Jay Lemmon Apr 3 '12 at 6:36
Maybe it is easier to try this with two squares first? Then all the integrals go from $0$ to $1$. – Bernhard Apr 4 '12 at 5:58

A straightforward way to test your answer is to use a Monte Carlo method to estimate it. The Matlab code below evenly picks random points within two triangles that are both symmetrical about the x-axis (simplifies code because the net gravitational force must act along the axis, but it could be easily adapted to allow other configurations). It calculates the gravitational force as 1/r^2 for each pair of point and the x-component of that force. It then simply gets the mean value of 1/r^2, and uses that to calculate the distance between the centres of action of the gravitational forces.

The code plots the points so you can see the two shapes. Change the value of x_offset to alter the distance between them, and change the conditions to alter the shapes of the triangles.

clear N=100000; %Pick N random points with x between 0 and 1 and y between -0.5 and 0.5 x1=rand(1,N); y1=rand(1,N)-0.5; %find which points are within a triangle and only retain those points in x1 %and y1 isintri1=find(abs(y1)<=0.5*x1); x1=x1(isintri1); y1=y1(isintri1); plot(x1,y1) hold on

x_offset = 2; %Pick N random points with x between x_offset and x_offset + 1 and y between -0.5 and 0.5 x2=rand(1,N)+x_offset; y2=rand(1,N)-0.5; %find which points are within a triangle and only retain those points in x2 %and y2 isintri2=find(abs(y2)<=0.5-0.5*(x2-x_offset)); x2=x2(isintri2); y2=y2(isintri2); plot(x2,y2)

%Make sure that the two sets of points are the same length min_len = min(length(x1),length(x2)); x2=x2(1:min_len); x1=x1(1:min_len); y2=y2(1:min_len); y1=y1(1:min_len);

%Calculate distances between corresponding random points in the two triangles distance_between_points = sqrt((x2-x1).^2+(y2-y1).^2); %Force proportional to 1/r^2 force = 1./distance_between_points.^2; %Calculate x-component of force x_comp=force.*(x2-x1)/distance_between_points; %Calculate mean x-component of force mean_x_comp=mean(x_comp) %Calculate equivalent ditance between point masses equiv_dist = sqrt(1/mean_x_comp)

-

Google for triangle mass center (WP).

Concentrate the mass of each triangle in the locus of their 'center of mass' then apply $1/r^2$ or $1/r$ law. Then substitute a pair of centers of mass by one center of mass equivalent, that lies in the line that conect them, you figure out the formula ;). Apply until only one centre of mass remains. This is the centre of mass of the system.

After comments: Yes, the objections are valid.
In particular I didn't realize that the triangles were close, Sorry.
The answer above serves only if they are far from each other.

If the objects are near we enter a tidal regime and we have to make an integration of 'all against all' .

In the this general case I would divide the surfaces into small enough rectangles the same size/mass and will use the centers as atoms where the forces are applied.

I will choose to use the universal gravitational law (Newton).

For each object: for each sub-object calculate the vector force due to all the sub-objects of the other object. For each object I would replace every two vectors for an equivalent resting on the right point on the line joining the surface elements. If the final resultant vector is is not centered in the center of mass then it will produce a torque that will make the object rotate.
The same reasoning would apply to other object.
In the NASA site we can find a fortran program to calculate the tidal force between the Moon and the Earth. It uses discretization and 'all against all' .

-
Are you sure you can just use the triangle centroids and treat them as point masses? I know you can for circles. But it's not obvious to me that you can treat all objects as point masses if you have arbitrary shapes like triangles. Consider the case of a long thin triangle near a very massive point. Wouldn't the gravity force cause a torque on the triangle? If so, we can't treat the triangle as a point mass, certainly. – Jay Lemmon Apr 3 '12 at 1:11
@JayLemmon: You can't. Center of mass in gravitation works only for bodies with angular symmetry(basically spheres) in 3D, circles in 2D(with $1/r$ law)--as you learned in the comments above. Center of mass is only really useful for rotational calculations and the like (in which case the moment of inertia is also required). – Manishearth Apr 3 '12 at 2:57
i did not said that they will not rotate but that they will converge to the colective centre of mass. If a triangle is long then it can be further subdivided into smaller triangles. if the bodies are near the tidal force is relevant and elasticity shoud be considered in the deformation of the materials. In the OP I did not noted that the triangles are near. Sorry. – Helder Velez Apr 3 '12 at 5:05
@Manishearth I do not understand your comment. en.wikipedia.org/wiki/Center_of_mass . The center of mass of any shape body is also the center of gravity. Depending on the distance between the two triangles, to first order it will be a good approximation to use the center of mass. When the distances are the same order of magnitude as the size of the triangle then higher order terms will enter because of the distribution of mass of the triangles.( including tides) – anna v Apr 3 '12 at 6:57
@annav: That's only in a uniform gravitational field. Yeah, you can approximate, but only if the bodies are pretty far away. The question states relatively close to each other – Manishearth Apr 3 '12 at 7:48