ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 30 Jul 2012 15:02:52 +02003D graphics bug?https://ask.sagemath.org/question/9177/3d-graphics-bug/Hi,
When I use the following code and I change the values of phi or theta, the previous red dot(point of projection) remains on the image and the new dot is added onto the image, giving two red dots. If I repeatedly change the values then more red dots appear. This problem does not occur if I get rid of the polygon inside the sphere. I'm not sure why this is happening...
---------------------------------
Works:
S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"),
phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(S + north_pole + point_of_projection)
--------------------------------
Doesn't work:
Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.show()
S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"), phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(Z_set_as_graphics + S + north_pole + point_of_projection)Tue, 24 Jul 2012 14:04:56 +0200https://ask.sagemath.org/question/9177/3d-graphics-bug/Comment by glee2 for <p>Hi,</p>
<p>When I use the following code and I change the values of phi or theta, the previous red dot(point of projection) remains on the image and the new dot is added onto the image, giving two red dots. If I repeatedly change the values then more red dots appear. This problem does not occur if I get rid of the polygon inside the sphere. I'm not sure why this is happening...</p>
<hr/>
<p>Works:</p>
<pre><code>S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"),
phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(S + north_pole + point_of_projection)
</code></pre>
<hr/>
<p>Doesn't work:</p>
<pre><code>Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.show()
S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"), phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(Z_set_as_graphics + S + north_pole + point_of_projection)
</code></pre>
https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19358#post-id-19358sorry! here's the code:Tue, 24 Jul 2012 14:25:07 +0200https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19358#post-id-19358Comment by kcrisman for <p>Hi,</p>
<p>When I use the following code and I change the values of phi or theta, the previous red dot(point of projection) remains on the image and the new dot is added onto the image, giving two red dots. If I repeatedly change the values then more red dots appear. This problem does not occur if I get rid of the polygon inside the sphere. I'm not sure why this is happening...</p>
<hr/>
<p>Works:</p>
<pre><code>S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"),
phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(S + north_pole + point_of_projection)
</code></pre>
<hr/>
<p>Doesn't work:</p>
<pre><code>Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.show()
S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"), phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(Z_set_as_graphics + S + north_pole + point_of_projection)
</code></pre>
https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19356#post-id-19356Ok, I pasted that above for clarity.Tue, 24 Jul 2012 14:54:40 +0200https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19356#post-id-19356Comment by kcrisman for <p>Hi,</p>
<p>When I use the following code and I change the values of phi or theta, the previous red dot(point of projection) remains on the image and the new dot is added onto the image, giving two red dots. If I repeatedly change the values then more red dots appear. This problem does not occur if I get rid of the polygon inside the sphere. I'm not sure why this is happening...</p>
<hr/>
<p>Works:</p>
<pre><code>S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"),
phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(S + north_pole + point_of_projection)
</code></pre>
<hr/>
<p>Doesn't work:</p>
<pre><code>Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.show()
S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"), phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(Z_set_as_graphics + S + north_pole + point_of_projection)
</code></pre>
https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19359#post-id-19359I just tried this, and don't get this behavior... maybe because you posted the version of the code without the polygon?Tue, 24 Jul 2012 14:14:57 +0200https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19359#post-id-19359Comment by glee2 for <p>Hi,</p>
<p>When I use the following code and I change the values of phi or theta, the previous red dot(point of projection) remains on the image and the new dot is added onto the image, giving two red dots. If I repeatedly change the values then more red dots appear. This problem does not occur if I get rid of the polygon inside the sphere. I'm not sure why this is happening...</p>
<hr/>
<p>Works:</p>
<pre><code>S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"),
phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(S + north_pole + point_of_projection)
</code></pre>
<hr/>
<p>Doesn't work:</p>
<pre><code>Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.show()
S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"), phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(Z_set_as_graphics + S + north_pole + point_of_projection)
</code></pre>
https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19357#post-id-19357Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.show()
S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"),
phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(Z_set_as_graphics + S + north_pole + point_of_projection)Tue, 24 Jul 2012 14:25:13 +0200https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19357#post-id-19357Comment by kcrisman for <p>Hi,</p>
<p>When I use the following code and I change the values of phi or theta, the previous red dot(point of projection) remains on the image and the new dot is added onto the image, giving two red dots. If I repeatedly change the values then more red dots appear. This problem does not occur if I get rid of the polygon inside the sphere. I'm not sure why this is happening...</p>
<hr/>
<p>Works:</p>
<pre><code>S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"),
phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(S + north_pole + point_of_projection)
</code></pre>
<hr/>
<p>Doesn't work:</p>
<pre><code>Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.show()
S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"), phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(Z_set_as_graphics + S + north_pole + point_of_projection)
</code></pre>
https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19355#post-id-19355I see it now. Like sunspots...Tue, 24 Jul 2012 14:56:18 +0200https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19355#post-id-19355Answer by Jason Grout for <p>Hi,</p>
<p>When I use the following code and I change the values of phi or theta, the previous red dot(point of projection) remains on the image and the new dot is added onto the image, giving two red dots. If I repeatedly change the values then more red dots appear. This problem does not occur if I get rid of the polygon inside the sphere. I'm not sure why this is happening...</p>
<hr/>
<p>Works:</p>
<pre><code>S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"),
phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(S + north_pole + point_of_projection)
</code></pre>
<hr/>
<p>Doesn't work:</p>
<pre><code>Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.show()
S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"), phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(Z_set_as_graphics + S + north_pole + point_of_projection)
</code></pre>
https://ask.sagemath.org/question/9177/3d-graphics-bug/?answer=13867#post-id-13867My guess is that this is just a manifestation of this bug: http://trac.sagemath.org/sage_trac/ticket/9089Mon, 30 Jul 2012 11:52:34 +0200https://ask.sagemath.org/question/9177/3d-graphics-bug/?answer=13867#post-id-13867Comment by kcrisman for <p>My guess is that this is just a manifestation of this bug: <a href="http://trac.sagemath.org/sage_trac/ticket/9089">http://trac.sagemath.org/sage_trac/ti...</a></p>
https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19315#post-id-19315Probably right.Mon, 30 Jul 2012 15:02:52 +0200https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19315#post-id-19315Answer by kcrisman for <p>Hi,</p>
<p>When I use the following code and I change the values of phi or theta, the previous red dot(point of projection) remains on the image and the new dot is added onto the image, giving two red dots. If I repeatedly change the values then more red dots appear. This problem does not occur if I get rid of the polygon inside the sphere. I'm not sure why this is happening...</p>
<hr/>
<p>Works:</p>
<pre><code>S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"),
phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(S + north_pole + point_of_projection)
</code></pre>
<hr/>
<p>Doesn't work:</p>
<pre><code>Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.show()
S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"), phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
show(Z_set_as_graphics + S + north_pole + point_of_projection)
</code></pre>
https://ask.sagemath.org/question/9177/3d-graphics-bug/?answer=13845#post-id-13845Okay, what I think is going on here is that `Polyhedron` doesn't really play nice with other graphics methods. It's probably pretty old (for Sage) code that stems from a time before we had lots of nice 3d options - maybe?
So in particular, the way it renders vertices is also via `point3d`
return point3d(self.coordinates_of(self.points), **kwds)
so my somewhat educated guess is that since you are adding things to `Z_set_as_graphics` (itself a hack you shouldn't have to do, but that's another story), *and* since you defined that *outside* the interact, it is adding those points to itself. So the following works.
S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"), phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.plot()
show(Z_set_as_graphics + S + north_pole + point_of_projection)
Note that you could make many of the other things interactive too, and could probably even get the outputs to the sliders to LaTeX up nicely...Tue, 24 Jul 2012 15:09:54 +0200https://ask.sagemath.org/question/9177/3d-graphics-bug/?answer=13845#post-id-13845Comment by kcrisman for <p>Okay, what I think is going on here is that <code>Polyhedron</code> doesn't really play nice with other graphics methods. It's probably pretty old (for Sage) code that stems from a time before we had lots of nice 3d options - maybe?</p>
<p>So in particular, the way it renders vertices is also via <code>point3d</code> </p>
<pre><code>return point3d(self.coordinates_of(self.points), **kwds)
</code></pre>
<p>so my somewhat educated guess is that since you are adding things to <code>Z_set_as_graphics</code> (itself a hack you shouldn't have to do, but that's another story), <em>and</em> since you defined that <em>outside</em> the interact, it is adding those points to itself. So the following works.</p>
<pre><code>S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"), phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.plot()
show(Z_set_as_graphics + S + north_pole + point_of_projection)
</code></pre>
<p>Note that you could make many of the other things interactive too, and could probably even get the outputs to the sliders to LaTeX up nicely...</p>
https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19354#post-id-19354I've made fixing this http://trac.sagemath.org/sage_trac/ticket/13288Tue, 24 Jul 2012 15:16:39 +0200https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19354#post-id-19354Comment by Jason Grout for <p>Okay, what I think is going on here is that <code>Polyhedron</code> doesn't really play nice with other graphics methods. It's probably pretty old (for Sage) code that stems from a time before we had lots of nice 3d options - maybe?</p>
<p>So in particular, the way it renders vertices is also via <code>point3d</code> </p>
<pre><code>return point3d(self.coordinates_of(self.points), **kwds)
</code></pre>
<p>so my somewhat educated guess is that since you are adding things to <code>Z_set_as_graphics</code> (itself a hack you shouldn't have to do, but that's another story), <em>and</em> since you defined that <em>outside</em> the interact, it is adding those points to itself. So the following works.</p>
<pre><code>S = sphere(size=10,color="yellow",opacity=0.5)
north_pole = point3d((0,0,10), color="blue")
r = 10
@interact
def _(theta = slider(0,2*pi,pi/20, default = pi/3, label="theta"), phi = slider(0,2*pi,pi/20, default = pi/4, label="phi")):
point_of_projection = point3d((r*sin(theta)*cos(phi),r*sin(theta)*sin(phi),r*cos(theta)), color="red")
Z = Polyhedron([[2,3,3],[3,0,3],[2,6,1],[1,0,1],[6,7,2]])
Z_set_as_graphics = Z.plot()
show(Z_set_as_graphics + S + north_pole + point_of_projection)
</code></pre>
<p>Note that you could make many of the other things interactive too, and could probably even get the outputs to the sliders to LaTeX up nicely...</p>
https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19321#post-id-19321My guess is that this is just a manifestation of this bug: http://trac.sagemath.org/sage_trac/ticket/9089Mon, 30 Jul 2012 11:51:30 +0200https://ask.sagemath.org/question/9177/3d-graphics-bug/?comment=19321#post-id-19321