ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 13 Aug 2011 14:57:01 -0500A way to rotate a tachyon plothttp://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/I can rotate a plot3d using the Java viewer, and then take an image. I'd like to use tachyon, but then how do I choose the right angle to take the picture?
I'd like to rotate the whole plot, or in other words, "place the camera in an arbitrary position"?Thu, 02 Jun 2011 00:00:12 -0500http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/Answer by niles for <p>I can rotate a plot3d using the Java viewer, and then take an image. I'd like to use tachyon, but then how do I choose the right angle to take the picture?</p>
<p>I'd like to rotate the whole plot, or in other words, "place the camera in an arbitrary position"?</p>
http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?answer=12403#post-id-12403Does the `.rotate()` method do what you want? Compare the output of:
sage: var('x,y')
(x, y)
sage: P = plot3d(sin(x*y), (x,-2,2), (y,-2,2))
sage: Q = P.rotate((0,0,1),pi/4)
sage: P.show(viewer='tachyon')
sage: Q.show(viewer='tachyon')
Thu, 02 Jun 2011 00:38:31 -0500http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?answer=12403#post-id-12403Comment by StevenPollack for <p>Does the <code>.rotate()</code> method do what you want? Compare the output of:</p>
<pre><code>sage: var('x,y')
(x, y)
sage: P = plot3d(sin(x*y), (x,-2,2), (y,-2,2))
sage: Q = P.rotate((0,0,1),pi/4)
sage: P.show(viewer='tachyon')
sage: Q.show(viewer='tachyon')
</code></pre>
http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?comment=21378#post-id-21378While this isn't my thread, I'd like to thank the poster: this totally answers a question I was wondering about.Sat, 13 Aug 2011 14:57:01 -0500http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?comment=21378#post-id-21378Comment by pang for <p>Does the <code>.rotate()</code> method do what you want? Compare the output of:</p>
<pre><code>sage: var('x,y')
(x, y)
sage: P = plot3d(sin(x*y), (x,-2,2), (y,-2,2))
sage: Q = P.rotate((0,0,1),pi/4)
sage: P.show(viewer='tachyon')
sage: Q.show(viewer='tachyon')
</code></pre>
http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?comment=21638#post-id-21638I can't believe I didn't see that one! I'll edit the question so that it's less confusing... but it wasn't a waste: I'll use the Tachyon stuff anyway.Thu, 02 Jun 2011 00:57:25 -0500http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?comment=21638#post-id-21638Answer by Kelvin Li for <p>I can rotate a plot3d using the Java viewer, and then take an image. I'd like to use tachyon, but then how do I choose the right angle to take the picture?</p>
<p>I'd like to rotate the whole plot, or in other words, "place the camera in an arbitrary position"?</p>
http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?answer=12394#post-id-12394Another option is the `sage.plot.plot3d.tachyon.Tachyon` interface (which is imported into the global namespace by default). Basically, you create a Tachyon scene instance, setup the contents of the scene, then render. Here is a slightly modified example from the `Tachyon` docstring:
sage: t = Tachyon(xres=512,yres=512, camera_center=(3,0.3,0), look_at=(0,0,0), updir=(0,0,1))
sage: t.light((4,3,2), 0.2, (1,1,1))
sage: t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0))
sage: t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0))
sage: t.texture('t2', ambient=0.2,diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0))
sage: k=0
sage: for i in srange(-1,1,0.05):
... k += 1
... t.sphere((i,i^2-0.5,i^3), 0.1, 't%s'%(k%3))
...
sage: t.show()
The key here is the first line--the arguments `camera_center`, `look_at`, and `updir`, which are quite self-explanatory.
The only problem with this mechanism is that you must directly use Tachyon's methods to construct objects instead of Sage's usual plotting interfaces. (`Graphics3d`, `plot3d`, `parametric_plot3d`, etc.)Thu, 02 Jun 2011 07:11:48 -0500http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?answer=12394#post-id-12394Comment by pang for <p>Another option is the <code>sage.plot.plot3d.tachyon.Tachyon</code> interface (which is imported into the global namespace by default). Basically, you create a Tachyon scene instance, setup the contents of the scene, then render. Here is a slightly modified example from the <code>Tachyon</code> docstring:</p>
<pre><code>sage: t = Tachyon(xres=512,yres=512, camera_center=(3,0.3,0), look_at=(0,0,0), updir=(0,0,1))
sage: t.light((4,3,2), 0.2, (1,1,1))
sage: t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0))
sage: t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0))
sage: t.texture('t2', ambient=0.2,diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0))
sage: k=0
sage: for i in srange(-1,1,0.05):
... k += 1
... t.sphere((i,i^2-0.5,i^3), 0.1, 't%s'%(k%3))
...
sage: t.show()
</code></pre>
<p>The key here is the first line--the arguments <code>camera_center</code>, <code>look_at</code>, and <code>updir</code>, which are quite self-explanatory.</p>
<p>The only problem with this mechanism is that you must directly use Tachyon's methods to construct objects instead of Sage's usual plotting interfaces. (<code>Graphics3d</code>, <code>plot3d</code>, <code>parametric_plot3d</code>, etc.)</p>
http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?comment=21611#post-id-21611That didn't work for me because I had several implicit_plot_3d. I was able to use a trick from http://ask.sagemath.org/question/20/the-tachyon-object-used-for-rendering-plots, but it was very verbose and a bit hacky. Thanks anyway, this might work for somebody else.Mon, 06 Jun 2011 23:57:28 -0500http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?comment=21611#post-id-21611Answer by v_2e for <p>I can rotate a plot3d using the Java viewer, and then take an image. I'd like to use tachyon, but then how do I choose the right angle to take the picture?</p>
<p>I'd like to rotate the whole plot, or in other words, "place the camera in an arbitrary position"?</p>
http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?answer=12574#post-id-12574 Unfortunately the `rotate()` method didn't work for my `implicit_plot3d` plot. It seems a bit strange. Why not making the additional options such as `camera_center` available via the `show()` method? There are some "extra_opts" parameter in `show()` method, but it is not clear how to use it and whether it is actually possible to pass the `camera_center` parameter through it.Sat, 13 Aug 2011 08:26:08 -0500http://ask.sagemath.org/question/8143/a-way-to-rotate-a-tachyon-plot/?answer=12574#post-id-12574