Equivalent of Mathematica's GraphicsComplex

asked 2025-07-30 23:24:50 +0200

azerbajdzan gravatar image

updated 2025-08-19 23:02:06 +0200

In Mathematica we have GraphicsComplex[points, Polygon[point_indicies], VertexTextureCoordinates -> uv]

points is list of points, point_indicies is list of tuples of indices for each face (polygon) and uv is uv mapping of some texture. uv is a list of pairs of coordinates.

What I found in Sagemath was IndexFaceSet, but it only has the first two arguments identical to Mathematica, there is no uv mapping argument only colors for each face.

Is there some other function that do the same as Mathematica's GraphicsComplex?

from sage.plot.plot3d.index_face_set import IndexFaceSet
from sage.plot.plot3d.texture import Texture
point_list = [(2,0,0),(0,2,0),(0,0,2),(0,1,1),(1,0,1),(1,1,0)]
face_list = [[0,4,5],[3,4,5],[2,3,4],[1,3,5]]
col = rainbow(4, 'rgbtuple')
t_list = [Texture(col[i]) for i in range(4)]
S = IndexFaceSet(face_list, point_list, texture_list=t_list)
S.show()

image description

Working Mathematica code:

mat = First@
   SubstitutionSystem[{a_ :> Table[a, 32, 32]}, 
    Table[Mod[i + j, 2], {i, 10}, {j, 10}], {1}];

Graphics[{Texture[Image@mat], EdgeForm[None], 
  GraphicsComplex[{{0, 0}, {1, 0}, {1/2, 1}}, Polygon[{1, 2, 3}], 
   VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1/4, 1}}]}]

image description

edit retag flag offensive close merge delete