-
-
Notifications
You must be signed in to change notification settings - Fork 490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a TikZ-tex output method for 2d and 3d polytopes #12083
Comments
comment:1
Do you have a ready patch already? Such functionality can be quite awesome in conjunction with SageTeX! |
comment:2
I just need to adapt the code a little bit. It is already mostly written and works with 'quite' big examples: A3,B3 and H3 permutahedra. I just need to sit and do it: it should be there in a week or so... |
Attachment: trac12083_tikz_polytope.patch.gz Addition of tikz method for polyhedron |
comment:3
Here is the patch. Please test it with your favorite 2d and 3d polytopes! |
Attachment: trac12083_tikz_polytope.2.patch.gz Addition of tikz method for polyhedron |
comment:4
Saving files in your test is not necessary. I suggest you do the test like this instead : sage: P1 = polytopes.small_rhombicuboctahedron()
sage: t = P1.tikz([1,3,5], 175, scale=4)
sage: type(t)
<type 'str'>
sage: print '\n'.join(t.splitlines()[:4])
\begin{tikzpicture}%
[x={(-0.939161cm, 0.244762cm)},
y={(0.097442cm, -0.482887cm)},
z={(0.329367cm, 0.840780cm)}, If you want to keep those line in the doc (a good idea a believe), I suggest you mark them as untested :
from subprocess import Popen, PIPE
from sage.misc.all import tmp_filename
-from sage.misc.functional import norm
+from sage.misc.functional import norm, n
from sage.misc.package import is_package_installed
sage-4.8:
sage-4.8 + your patch:
from sage.modules.free_module_element import vector
+from sage.modules.free_module import VectorSpace
from sage.matrix.constructor import matrix, identity_matrix In your code, you write :
I suggest you change this to :
I believe the problem comes from this : + 2) Select ``Console`;
+ 3) Select the tab ``State`;
to
It will look nicer in the documentation.
See www.sagemath.org/doc/developer/conventions.html I suggest you follow this example :
So, first say what is the type. Then, say what is the default (inside For the output, just say the type and what it is. The part
I know it is a vector. Is it the camera position? Is it the view angle? Is it the axis for the rotation?
Compare Bonne fête ! |
Apply over the precedent patch |
This comment has been minimized.
This comment has been minimized.
comment:5
Attachment: trac12083_tikz_polytope_review.patch.gz |
Attachment: trac_12083_unholy_rebase_to_sage-5.0.patch.gz For illustrative purposes only |
comment:6
I really like this functionality and I thought I'd help by rebasing the patch to sage-5.0, but I have now run out of time. Working on this reminded me of some things I don't like about the Projection class, but I am not sure about the best way to fix them. I think projections should be more accessible from Polyhedron objects, and vice-versa. Anyway, I did complete a patch for sage-5.0 that manages to pass the original tests, but its not very pretty. Its inefficient, and relies on a parent_polyhedron method for projections that might be objectionable. But since it works, it might be helpful in creating a better version. If no one else does, I might have time to revisit this in a week or so. |
comment:7
So - which patches have to be applied? I suspect they'll need rebasing after all Volker's refactoring. |
Author: Jean-Philippe Labbé |
Reviewer: Sébastien Labbé |
comment:8
let us try and see apply trac12083_tikz_polytope.2.patch trac12083_tikz_polytope_review.patch |
comment:9
So, today I used the reviewed patch to draw a polytope using the library decorations of tikz. I realized that I was sloppy to implement the edges; they are drawn twice. This also makes the compilation in LaTeX slower. I will write a patch for version 5.3 that does not have repetitions (and containing the improvements in the rebased version). |
comment:10
Attachment: trac12083_rebased_5.4.1.patch.gz So, here is the rebased version of the patch. I solved a few problems: I looked at the compiled tikz output examples and now everything seems in order. All tests passed on 5.4.1 One thing I don't really like though is the fact that we need to pass to projections to access the tikz method. Perhaps a wrapper would do the thing? |
comment:11
For the bot: apply trac12083_rebased_5.4.1.patch |
comment:12
There is a problem with the lines
which appear three times, but the variables v1 and v2 are never used. |
comment:13
Moreover, three tests are failing on sage 5.8.beta1 |
comment:14
This patch should probably be rebased. It would be nice to add in the ticket's description which patch are to be applied, too. Nathann |
This comment has been minimized.
This comment has been minimized.
comment:16
here is a rebased patch, passing tests and working on 5.12.beta0 apply only trac12083_rebased_5.12.patch |
comment:17
apply only trac12083_rebased_5.12.patch |
Changed reviewer from Sébastien Labbé to Sébastien Labbé, Volker Braun |
comment:18
lgtm |
comment:19
The PDF doc doesn't build:
To fix this, use |
Attachment: trac12083_rebased_5.12.patch.gz |
comment:21
I have made a corrected patch, hopefully. apply trac12083_rebased_5.12.patch |
comment:22
Works for me... |
Merged: sage-5.13.beta3 |
comment:24
I just want to say that I could have used this a couple years ago and instead had to do lots of guess-and-check with graph plots, then convert to xfig... thank you, this will be very useful! |
I recently had to draw polytopes for my work.
Many drawing tools already exist. But none of them satisfied me.
So far, I wrote a method that takes a polytope in 3d and a view-angle (taken from Jmol) and outputs a .tex file containing a TikZ image of the polytope.
The method should also be able to deal with 2-polytopes.
The result is highly customizable: colors, edge style, vertices style, etc...
First review: I made the suggested corrections. They are present in the patch trac12083_tikz_polytope_review.patch
Test passed on version 4.7.2
Apply attachment: trac12083_rebased_5.12.patch
Component: geometry
Keywords: TikZ, polytope
Author: Jean-Philippe Labbé
Reviewer: Sébastien Labbé, Volker Braun
Merged: sage-5.13.beta3
Issue created by migration from https://trac.sagemath.org/ticket/12083
The text was updated successfully, but these errors were encountered: