0

this post is discussing the conversion from barycentric coordinates to Cartesian coordinates.

enter image description here

it seems that the figure (fig_1) only illustrates 3 points

B(0,0,1), A(0,1,0), C(1,0,0)

i am trying to understand the conversion, here is my code

x_inner = np.array([0.375, 0.5  , 0.625, 0.375])
y_inner = np.array([0.21650635, 0.4330127 , 0.21650635, 0.21650635])
x_outer = np.array([0. , 0.5, 1. , 0. ])
y_outer = np.array([0.       , 0.8660254, 0.       , 0.       ])
plt.plot(x_outer,y_outer)
plt.plot(x_inner,y_inner,c='tab:orange')
plt.scatter(x_outer, y_outer)
plt.scatter(x_inner, y_inner)

the values constitute the coordinates array come from the original post.

here is the output.

enter image description here

the inner orange triangle consists of 3 vertices which correspond to the points (1/4,1/4,1/2), (1/4,1/2,1/4), (1/2,1/4,1/4) in original barycentric coordinates.

the question is, how to get a smaller triangle like 1/10 of the orange one.

ps: sorry for fig_1 doesn't match the true values.

Jay
  • 400
  • 1
  • 4
  • 13

2 Answers2

0

Let we want to built small triangle similar to large one, centered at the same centroid. Centroid is point of median intersection, it divides them in ration 2:1, and has B.C. (baricentric coordinates) (1/3, 1/3, 1/3).

Vertex of such small triangle at the first median has B.C. like (g,f,f), where g+f+f=1, at the second median (f,g,f), and (f,f,g) at the third one. We can see that for g=1/3 triangle size is zero (coefficient cf= 0), for g=1 triangle is equal to large triangle (cf = 0).

For intermediate values just make linear interpolation

 cf = (g - 1/3) * 3/2 = 3/2 * g - 1/2 = (3 * g - 1) / 2
 vice versa
 g = (cf + 1/2) * 2/3 = (2 * cf + 1) / 3
 f = (1 - g) / 2

So we can build, for example, triangle with half-size

cf = 1/2
g = 2/3
f = 1/6
(2/3, 1/6, 1/6)     (1/6, 2/3, 1/6)     (1/6, 1/6, 2/3)

Note that for g<1/3 we'll get small triangle with inverted orientation (cf negative)

MBo
  • 77,366
  • 5
  • 53
  • 86
  • thanks for your answer. what do f, g and c stand for respectively? i guess c stands for centroid. –  May 28 '19 at 08:36
  • 1
    f and g are components of baricentric coordinates, CF is coefficient (size of small triangle / size of large triangle) – MBo May 28 '19 at 08:38
  • thanks to your comment on question, I got a clearer question, you are so cool. why does the system have 3 median? the small triangle and the big one have the same centroid, which means there is only one median, what am i missing? –  May 28 '19 at 08:48
  • 1
    Triangle has three medians - they are segments connecting verices with middles of opposite sides https://en.wikipedia.org/wiki/Median_(geometry) – MBo May 28 '19 at 08:50
0

Consider a triangle ABC and a scaling factor r > 0.

The centroid of ABC is G := (A + B + C) / 3. We want to perform a uniform scaling by r that keeps G fixed. This transformation is given by h(V) := G + (V - G) * r.

To obtain the scaled triangle, A'B'C', we apply h to each of the vertices of ABC:

A' := h(A) = A * (1+2*r)/3 + B * (1-r)/3   + C * (1-r)/3
B' := h(B) = A * (1-r)/3   + B * (1+2*r)/3 + C * (1-r)/3
C' := h(C) = A * (1-r)/3   + B * (1-r)/3   + C * (1+2*r)/3

The coefficients above are barycentric coordinates.

In the case of your inner triangle r = 1/4.