Faces

Prerequisites

Vertices Show

Faces

Introduction

  • A face is a collection of vertices.
  • Usually, Each face is a triangle, meaning 3 vertices are used to define it.
  • Example: faces of a cube

Code (Python)

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import art3d

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

vertices = np.array([[0,0,0], [1,0,0], [1,1,0], [0,1,0], [0,0,1], [1,0,1], [1,1,1], [0,1,1]])

# each number is the index of a vertex in the vertices array
faces = [[3, 2, 1],
         [3, 1, 0],
         [5, 1, 0],
         [5, 4, 0],
         [7, 3, 0],
         [7, 4, 0],
         [6, 2, 1],
         [6, 5, 1],
         [6, 3, 2],
         [6, 7, 3],
         [6, 5, 4],
         [6, 7, 4]]

pc = art3d.Poly3DCollection(vertices[faces], edgecolor="black")
ax.add_collection(pc)

plt.show()