# Barycenter of 3 points

### #1

Posted 14 November 2010 - 10:50 AM

See, suppose I've got all the coords, all of them. And :

G barycenter of (A,a) (B,b) and (C,c) ;ABC a triangle.

And I need to calculate the a,b and c.

Well you might think, what is this for?

I just need it for my painting tool. Thx in advance.

immm, I know these function :

Gx= (a*Ax+b*Bx+c*Cx) / (a+b+c)

Gy= .... Etc ...

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #2

Posted 14 November 2010 - 12:31 PM

You want to calculate the coordinates of a triangle, that has a barycenter located at G ? There's an infinity of possible triangles whose barycenter is G.Ok I know what a barycenter is; but I need to reverse the process.

See, suppose I've got all the coords, all of them. And :

G barycenter of (A,a) (B,b) and (C,c) ;ABC a triangle.

And I need to calculate the a,b and c.

Maybe you could explain more carefully what you want.

### #3

Posted 14 November 2010 - 01:30 PM

If you've got all the coordinates, where does the 'barycenter' come into it?See, suppose I've got all the coords, all of them. And :

G barycenter of (A,a) (B,b) and (C,c) ;ABC a triangle.

And I need to calculate the a,b and c.

**Anti-Decompiler** for GM6.1 to GM8.1.91! [Main skin by Sindarin]

Discontinued.

^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.

### #4

Posted 14 November 2010 - 03:02 PM

So he knows only the x values of the triangle but not the y values.

### #5

Posted 14 November 2010 - 03:37 PM

Ok here it is :

I am now able to calculate the intersection between a 3D model triangle and the mouse vector.

Suppose G the point of intersection.

ABC the triangle points.

So we can admit that G is the Barycenter of (A,a) , (B,b) and (C,c)

If I'll be able to calculate a,b and c, I will be able to calculate G pos on the UVmap.

And I know all the coords. ALL of them. Thx

**Edited by The Scorpion, 14 November 2010 - 03:38 PM.**

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #6

Posted 14 November 2010 - 07:15 PM

You need to define some of your "terms":

1) What do you mean by "mouse vector"? You mean the mouse screen position?

2) Is the triangle really defined in 3-space? Or in the screen plane?

3) What do you mean by (A,a),(B,b) and (C,c)? Or these the X,Y coordinates?

Better yet, draw us a picture.

### #7

Posted 14 November 2010 - 08:31 PM

The process is fully 3d.

ok, suppose ther is a point G(gx,gy,gz) that belongs to a plane (P) in 3d

ABC a triangle also icluded in (P)

Ok so we can say that G is the Barycenter of (A,a: val) (B,b) and (C,c)

Do I need to explain what a barycenter is?

Suppose that I have all the points coords.

How can I calculate a,b and c ?

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #8

Posted 14 November 2010 - 08:39 PM

-IMP

Are you an artist who likes creating original creature designs? Maybe you can help out with Elementa here! Give it a look; you might like the idea

### #9

Posted 14 November 2010 - 08:57 PM

I'll assume you all know what a brycenter is.

exemple :

If G is the Barycenter of (A,2) (B,3) and (C,8) we can get the G coords by : Gx= ( 2 * Ax + 3 * Bx + 8 * Cx) / (2 + 3 + 8) same thing with Gy and Gz, but replace all x coords with y and z coords.

Get it?????

Now to reverse the Process, I know all the coords, but I need to calculate a,b,c?

If I'll have to explain this one more time, I'll close the Topic. Please People, I thought this won't Take more than 2 hours to be solved.

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #10

Posted 14 November 2010 - 08:58 PM

Do I need to explain what a barycenter is?

No, you need to explain what (A, a) means.

### #11

Posted 14 November 2010 - 09:09 PM

Is that what you mean by (A,a), (B,b) etc?

### #12

Posted 14 November 2010 - 09:25 PM

http://www.fmaths.co...nter/lesson.php

(A,a) means that the Point (A) with coords (Ax,Ay,Az)

get tha value (a) as a coefficient.

Sorry if My math English words are incorrect.

If you knew what a barycenter is, you'll immediately understand what (A,a) is.

**Edited by The Scorpion, 14 November 2010 - 09:32 PM.**

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #13

Posted 14 November 2010 - 11:24 PM

If all of the vertices have the same weight, then simply find the average of each of the components. Otherwise, you'll do a weighted average to find the center of mass.

However, this process clearly isn't reversible since you are taking a collection of ordered triplets and getting a resulting singlet, of which is not unique. So there isn't a (unique) way of reversing this process.

### #14

Posted 16 November 2010 - 06:35 PM

I know that it's a 3 equations system.

But you see I'm not that good at math.

First it's not a center of mass. It's a barycenter of

**3**points.

Second, I'm ,if you like looking for these weights.

Ok here it is, if out of 3 points ABC, I get a Barycenter G at a particular Position in the space, How can I calculate the 3 points A,B and C masses ?

So far tha'ts what I got :

if

a=alfa b=beta c=gamma Gx = ( a * Ax + b*Bx + c* Cx) / ( a+b+c)

Then

a * Ax = Gx * (a+b+c) - b*Bx - c*Cx a - a * (Gx /Ax) = (b*Gx + c*Gx - b * Bx - c*Cx ) / Ax a = ( (b*Gx + c*Gx - b * Bx - c*Cx ) / Ax ) / (1- Gx/Ax)

Pls I want you to check if my calculs are correct.

if we do the same with BETA and Gamme

we can get a 3 equations system :

a = ( (b*Gx + c*Gx - b * Bx - c*Cx ) / Ax ) / (1- Gx/Ax) b = ( (a*Gx + c*Gx - a * Ax - c*Cx ) / Bx ) / (1- Gx/Bx) a = ( (b*Gx + a*Gx - b * Bx - a*Ax ) / Cx ) / (1- Gx/Cx)

See that simple, Because I haven't Got so far in Math Studies (system of 3 equations)

I need help to calculate (a,b and c)

Thanks for everyone, I know you're trying to Help, But seriously, it was not that obvious.

**Edited by The Scorpion, 16 November 2010 - 06:52 PM.**

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #15

Posted 16 November 2010 - 07:08 PM

If you have what you're saying:

eqn1 = Gx == a Ax / (a + b + c) + b Bx / (a + b + c) + c Cx / (a + b + c)

eqn2 = Gy == a Ay / (a + b + c) + b By / (a + b + c) + c Cy / (a + b + c)

eqn3 = Gz == a Az / (a + b + c) + b By / (a + b + c) + c Cz / (a + b + c)

Then your goal hopefully is to find a, b, c, given that you have Gx, Gy, Gz, etc.

Unfortunately, Mathematica does not yield a solution to this.

### #16

Posted 17 November 2010 - 10:20 AM

I see, you are strictly working with three points and three coefficients.

If you have what you're saying:

eqn1 = Gx == a Ax / (a + b + c) + b Bx / (a + b + c) + c Cx / (a + b + c)

eqn2 = Gy == a Ay / (a + b + c) + b By / (a + b + c) + c Cy / (a + b + c)

eqn3 = Gz == a Az / (a + b + c) + b By / (a + b + c) + c Cz / (a + b + c)

Then your goal hopefully is to find a, b, c, given that you have Gx, Gy, Gz, etc.

Unfortunately, Mathematica does not yield a solution to this.

Why is that I think it's possible, If we can express

a = (expression that does not contain (a) as a variable)

b and c as well, then this system can be solved.

I know that such math exists but I don't know the process.

I know Gx,Gy,Gz, as well as Ax,Ay,Az,Bx,By ... all the coords are known.

Does this help now?

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #17

Posted 17 November 2010 - 01:34 PM

Go ahead and try that. I think you'll find those quadratic terms make it difficult.If we can express

a = (expression that does not contain (a) as a variable)

b and c as well, then this system can be solved.

A simple algebraic approach (reducing the number of variables by substitution) won't work here. You'll need to be more clever.

### #18

Posted 17 November 2010 - 04:45 PM

Probably because there isn't a unique solution? For instance, if (a, b, c) = (1, 2, 3) satisfies the equation, then (2, 4, 6), (3, 6, 9), (10, 20, 30) and so on will also satisfy it.Unfortunately, Mathematica does not yield a solution to this.

I think you need an additional constraint. For example, assume that we know the total weight of those three points. Let a+b+c=M that is a constant. Then we get the following simultaneous equations that is solvable:

Gx = a'Ax + b'Bx + c'Cx

Gy = a'Ay + b'By + c'Cy

Gz = a'Az + b'Bz + c'Cz

where a'=a/M, b'=b/M and c'=c/M.

**Edited by torigara, 17 November 2010 - 05:43 PM.**

### #19

Posted 17 November 2010 - 06:04 PM

Probably because there isn't a unique solution? For instance, if (a, b, c) = (1, 2, 3) satisfies the equation, then (2, 4, 6), (3, 6, 9), (10, 20, 30) and so on will also satisfy it.Unfortunately, Mathematica does not yield a solution to this.

I think you need an additional constraint. For example, assume that we know the total weight of those three points. Let a+b+c=M that is a constant. Then we get the following simultaneous equations that is solvable:

Gx = a'Ax + b'Bx + c'Cx

Gy = a'Ay + b'By + c'Cy

Gz = a'Az + b'Bz + c'Cz

where a'=a/M, b'=b/M and c'=c/M.

I don't really follow you in here. But here comes an idea, If we suppose that a=1

then this will became 2 equations system.

Is this correct?

**Edited by The Scorpion, 17 November 2010 - 06:05 PM.**

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #20

Posted 17 November 2010 - 09:08 PM

Probably because there isn't a unique solution? For instance, if (a, b, c) = (1, 2, 3) satisfies the equation, then (2, 4, 6), (3, 6, 9), (10, 20, 30) and so on will also satisfy it.

Usually Mathematica will give you every solution, even ones you don't want. Perhaps I was erroneous on the equations that I entered. There obviously are solutions, but getting them might not be doable through algebraic means. Using the constraint does yield a solution, of course, since it results in a linear equation, and its just as one would expect it to be.

I don't really follow you in here. But here comes an idea, If we suppose that a=1

then this will became 2 equations system.

Is this correct?

Don't approach the problem like this. Instead, just solve the system of three equations and three unknowns.

### #21

Posted 18 November 2010 - 02:26 AM

I don't know much about Mathematica, but does it give solutions when there is anUsually Mathematica will give you every solution, even ones you don't want.

*infinite*number of them?

The problem here is that, when a set of numbers (a

_{0}, b

_{0}, c

_{0}) is a solution, then (n*a

_{0}, n*b

_{0}, n*c

_{0}) is also a solution for all n (except 0.) Actually, G is determined by the

*ratio*a:b:c.

Sorta correct; that's another way to add a constraint (by putting 1:bIf we suppose that a=1 then this will became 2 equations system.

Is this correct?

_{1}:c

_{1}=a:b:c to obtain one of solutions.)

If you don't still follow, consider the following scales as a simplified example. Given the mass of each weight, it is easy to determine the balancing point C.

| | +--------+-----------------+ | C | +--+--+ +--+--+ | 50g | | 25g | | | +-----+ +-----+ |<------>|<--------------->| 10cm 20cmHowever, the reverse isn't generally possible. If weights are unknown, all we can tell is that M1=2*M2 (or M1:M2=2:1) unless there is additional information (e.g. M1 is a constant.)

| | +--------+-----------------+ | C | +--+--+ +--+--+ | ? | | ? | | | +-----+ +-----+ M2 M1 |<------>|<--------------->| 10cm 20cm

As for solving the problem: supposing that , the aforementioned three equations are tranformed as following.

a(Ax-Gx) + b(Bx-Gx) + c(Cx-Gx) = 0

a(Ay-Gy) + b(By-Gy) + c(Cy-Gy) = 0

a(Az-Gz) + b(Bz-Gz) + c(Cz-Gz) = 0

The first one represents a 3-d plane whose normal vector is (Ax-Gx, Bx-Gx, Cx-Gx) and passes the point (0, 0, 0). The latter two represent other planes all passing (0, 0, 0). Solving the above simultaneous equations is equivalent to finding the intersection of those three planes. It is apparent that they intersect at (0, 0, 0), but it isn't the solution because of the restriction that a+b+c is not 0. To have intersection point other than (0, 0, 0), all of three planes must share the same intersection line (i.e. their normal vector is on a same plane.) All solutions lie on this common intersection line.

So, we only have to calculate the intersection line between the first two (the other one also shares the same line.) Now, let the direction vector of the intersection line (Va, Vb, Vc). This is perpendicular to the normal vector of two planes. So, just calculate the cross production:

Va = (Bx-Gx) * (Cy-Gy) - (Cx-Gx) * (By-Gy)

Vb = (Cx-Gx) * (Ay-Gy) - (Ax-Gx) * (Cy-Gy)

Vc = (Ax-Gx) * (By-Gy) - (Bx-Gx) * (Ay-Gy)

Choose an arbitray number t (that is not 0), then you can derive a, b and c as:

a = t * Va

b = t * Vb

c = t * Vc

**Edited by torigara, 18 November 2010 - 10:51 AM.**

### #22

Posted 18 November 2010 - 03:11 AM

I don't know much about Mathematica, but does it give solutions when there is an infinite number of them?

Typically yes--it'll write everything in terms of some free variables. If you had three unknowns and two equations, it'll get it down to one equation.

### #23

Posted 18 November 2010 - 07:21 AM

I don't really follow you in here. But here comes an idea, If we suppose that a=1

then this will became 2 equations system.

Is this correct?

Don't approach the problem like this. Instead, just solve the system of three equations and three unknowns.

Ok, I'll try that. thx any way

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #24

Posted 18 November 2010 - 12:13 PM

I don't know much about Mathematica, but does it give solutions when there is anUsually Mathematica will give you every solution, even ones you don't want.

infinitenumber of them?

The problem here is that, when a set of numbers (a_{0}, b_{0}, c_{0}) is a solution, then (n*a_{0}, n*b_{0}, n*c_{0}) is also a solution for all n (except 0.) Actually, G is determined by theratioa:b:c.Sorta correct; that's another way to add a constraint (by putting 1:bIf we suppose that a=1 then this will became 2 equations system.

Is this correct?_{1}:c_{1}=a:b:c to obtain one of solutions.)

If you don't still follow, consider the following scales as a simplified example. Given the mass of each weight, it is easy to determine the balancing point C.| | +--------+-----------------+ | C | +--+--+ +--+--+ | 50g | | 25g | | | +-----+ +-----+ |<------>|<--------------->| 10cm 20cmHowever, the reverse isn't generally possible. If weights are unknown, all we can tell is that M1=2*M2 (or M1:M2=2:1) unless there is additional information (e.g. M1 is a constant.)| | +--------+-----------------+ | C | +--+--+ +--+--+ | ? | | ? | | | +-----+ +-----+ M2 M1 |<------>|<--------------->| 10cm 20cm

As for solving the problem: supposing that , the aforementioned three equations are tranformed as following.

a(Ax-Gx) + b(Bx-Gx) + c(Cx-Gx) = 0

a(Ay-Gy) + b(By-Gy) + c(Cy-Gy) = 0

a(Az-Gz) + b(Bz-Gz) + c(Cz-Gz) = 0

The first one represents a 3-d plane whose normal vector is (Ax-Gx, Bx-Gx, Cx-Gx) and passes the point (0, 0, 0). The latter two represent other planes all passing (0, 0, 0). Solving the above simultaneous equations is equivalent to finding the intersection of those three planes. It is apparent that they intersect at (0, 0, 0), but it isn't the solution because of the restriction that a+b+c is not 0. To have intersection point other than (0, 0, 0), all of three planes must share the same intersection line (i.e. their normal vector is on a same plane.) All solutions lie on this common intersection line.

So, we only have to calculate the intersection line between the first two (the other one also shares the same line.) Now, let the direction vector of the intersection line (Va, Vb, Vc). This is perpendicular to the normal vector of two planes. So, just calculate the cross production:

Va = (Bx-Gx) * (Cy-Gy) - (Cx-Gx) * (By-Gy)

Vb = (Cx-Gx) * (Ay-Gy) - (Ax-Gx) * (Cy-Gy)

Vc = (Ax-Gx) * (By-Gy) - (Bx-Gx) * (Ay-Gy)

Choose an arbitray number t (that is not 0), then you can derive a, b and c as:

a = t * Va

b = t * Vb

c = t * Vc

Thx torigara, It Actually work

I don't know what to say, soory for the late respond,

I actually missed this reply yesterday. Thx again.

Ok can I ask one last thing, can you rewrite

Va,Vb and Vc with (x and z coords) and if possible too (zy)

thank you very much if you do that

**Edited by The Scorpion, 18 November 2010 - 01:43 PM.**

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #25

Posted 19 November 2010 - 02:26 PM

Well, why do you need it? It is the same answer. Anyway, it's a simple transposition: just replace all y with z.Ok can I ask one last thing, can you rewrite

Va,Vb and Vc with (x and z coords) and if possible too (zy)

### #26

Posted 20 November 2010 - 02:48 AM

I see, you are strictly working with three points and three coefficients.

If you have what you're saying:

eqn1 = Gx == a Ax / (a + b + c) + b Bx / (a + b + c) + c Cx / (a + b + c)

eqn2 = Gy == a Ay / (a + b + c) + b By / (a + b + c) + c Cy / (a + b + c)

eqn3 = Gz == a Az / (a + b + c) + b By / (a + b + c) + c Cz / (a + b + c)

Then your goal hopefully is to find a, b, c, given that you have Gx, Gy, Gz, etc.

Unfortunately, Mathematica does not yield a solution to this.

Using these equations exactly yields a solution for a and b in terms of c in Mathematica. This makes sense because it characterizes the infinity of solutions (since there's one degree of freedom).

### #27

Posted 20 November 2010 - 12:49 PM

Well, why do you need it? It is the same answer. Anyway, it's a simple transposition: just replace all y with z.

Well suppose that a tiangle that its X or Y coords are all the same, the Equation will always be 0. See! Thx for the reply, it helped too.

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #28

Posted 04 December 2010 - 06:19 AM

Take a triangular sheet and put on it, at point A, a 1 kg weight, at point B, a 2kg weight, and at point C a 3kg weight. The barycenter of the system ponderates points is the centre of gravity of the sheet, that means the point where the sheet is balanced. Call it G. You guess that G will be closer to C than to A. G verifies the vector equality : propriete barycenter

In general, the barycenter G of ponderates points verifies :

propriete fondamentale du barycenter

How to build a barycenter :

To draw it, decompose 2 of the 3 vectors according to the vectors you can already build. Long but simple :

calculation construction barycenter

So G is here :

vecteurs triangle

### #29

Posted 04 December 2010 - 12:13 PM

triangle

Take a triangular sheet and put on it, at point A, a 1 kg weight, at point B, a 2kg weight, and at point C a 3kg weight. The barycenter of the system ponderates points is the centre of gravity of the sheet, that means the point where the sheet is balanced. Call it G. You guess that G will be closer to C than to A. G verifies the vector equality : propriete barycenter

In general, the barycenter G of ponderates points verifies :

propriete fondamentale du barycenter

How to build a barycenter :

To draw it, decompose 2 of the 3 vectors according to the vectors you can already build. Long but simple :

calculation construction barycenter

So G is here :

vecteurs triangle

I'm not really following you here, Any way I solved the problem.

Thx fot the reply.

Blender/3DMAX7 Animations to GM link

3D Animation 3Dmax11 to GameMaker link

### #30

Posted 04 December 2010 - 12:27 PM

Finally somebody explained this clearly without all those damn fool equations.The barycenter of the system ponderates points is the centre of gravity of the sheet, that means the point where the sheet is balanced. Call it G. You guess that G will be closer to C than to A. G verifies the vector equality : propriete barycenter

In general, the barycenter G of ponderates points verifies