Skip to content

barycenters

barycenters(V, F)

List of element barycenters for triangle mesh or polyline

Parameters:

Name Type Description Default
V (n,3) array

Vertex coordinates.

required
F (m,3) array

Face / edge indices.

required

Returns:

Name Type Description
B (m,3) array

Barycenter coordinates, the i-th row is the barycenter of the i-th face.

Examples:

V = np.array([[0,0,0],[1,0,0],[0,1,0],[0,0,1]])
F = np.array([[0,1,2],[0,1,3]])
B = barycenters(V,F)
Source code in src/gpytoolbox/barycenters.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def barycenters(V,F):
    """
    List of element barycenters for triangle mesh or polyline

    Parameters
    ----------
    V : (n,3) array
        Vertex coordinates.
    F : (m,3) array
        Face / edge indices.

    Returns
    -------
    B : (m,3) array
        Barycenter coordinates, the i-th row is the barycenter of the i-th face.

    Examples
    --------
    ```python
    V = np.array([[0,0,0],[1,0,0],[0,1,0],[0,0,1]])
    F = np.array([[0,1,2],[0,1,3]])
    B = barycenters(V,F)
    ```
    """     

    B = np.zeros((F.shape[0],V.shape[1]))
    for i in range(F.shape[1]):
        B += V[F[:,i],:]
    B /= F.shape[1]
    return B