bstone / Visualize-M2

A Macaulay2 (https://github.com/Macaulay2/M2) package to help visualize algebraic objects in the browser using javascript.
7 stars 1 forks source link

Add "Export to TikZ" functionality for SimplicialComplex.m2 #30

Closed bstone closed 8 years ago

bbarwick commented 9 years ago

This code should be almost identical to the code in exportTikz for visGraph2d.js, except we also need to add code to shade in the 2-dimensional triangular faces. I think we should just shade them with a light shade of grey and give them some transparency, letting TikZ handle the darker shading where faces overlap. In the 3-dimensional case, we will need to compute the projections of the points onto the viewing plane and also decide how we want to handle differentiating a full 3-simplex like subsets({a,b,c,d}) from a similar complex whose facets are {{a,b,c},{a,b,d},{a,c,d},{b,c,d}} (i.e., the complex obtained by removing the tetrahedron {a,b,c,d}). How should TikZ handle shading in a full tetrahedron differently than just shading its faces? Also should it hide vertices that are behind faces?

bbarwick commented 8 years ago

The visSimplicialComplex2d code is essentially complete and is ready for some shaded TikZ triangles. The global variable nodes stores the nodes as an array of arrays of the form [[name: node name, id: node id, ...], ... ], links stores the 1-dimensional faces as an array of arrays of the form [[source: node 1, target: node 2], ...], and faces stores the 2-dimensional faces as an array of arrays of the form [[v1: node 1, v2: node 2, v3: node 3], ...]. So, for example, given a 2-simplex f, we could find the coordinates of its three vertices by:

x1 = f.v1.x;
y1 = f.v1.y;
x2 = f.v2.x;
y2 = f.v2.y;
x3 = f.v3.x;
y3 = f.v3.y;
bstone commented 8 years ago

This is done. Here is a sample:

image

turns into this

image

bstone commented 8 years ago

Crap. I need to change the new commands. I think I called the commands something to common. For example the list of points is called \points in the LaTeX file. It is quite possible the user would have that as a command as well. I need to use something like a timestamp for this.

Also, I don't think you can have two images of a simplicial complex in the same file. I also need to fix this.

bstone commented 8 years ago

TIL that you can't use numbers in latex macros. Lame.

bstone commented 8 years ago

I fixed the timestamp but have not figured out how to show two complexes in one file.

bstone commented 8 years ago

ok, now it is completed.