Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Equivalent of Mathematica's GraphicsComplex

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 s 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(10, 'rgbtuple')
t_list = [Texture(col[i]) for i in range(10)]
S = IndexFaceSet(face_list, point_list, texture_list=t_list)
S.show(viewer='tachyon')

Equivalent of Mathematica's GraphicsComplex

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 s 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(10, 'rgbtuple')
t_list = [Texture(col[i]) for i in range(10)]
S = IndexFaceSet(face_list, point_list, texture_list=t_list)
S.show(viewer='tachyon')

Equivalent of Mathematica's GraphicsComplex

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(10, rainbow(4, 'rgbtuple')
t_list = [Texture(col[i]) for i in range(10)]
range(4)]
S = IndexFaceSet(face_list, point_list, texture_list=t_list)
S.show(viewer='tachyon')
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