Bug when rotating compound 180 degrees after rotating it immediately before

75 views
Skip to first unread message

Heidal

unread,
Aug 26, 2021, 8:45:17 PM8/26/21
to VPython-users

When I run the program below in python, the compound (comp) does the first rotation fine, but the 180 degree rotation moves it to the correct location but does not change its orientation.

comp.png

from vpython import *

XY_COORDS = [vec(0,0,0), vec(1,0,0), vec(1,1,0), vec(0,1,0)]
ZX_COORDS = [vec(0,0,0), vec(0,0,1), vec(1,0,1), vec(1,0,0)]

def make_quad(vecs, color):
    return quad( vs=[vertex( pos=vector, color=color) for vector in vecs])

def make_edge(colors):
    return compound( [make_quad(vecs, color) for (vecs, color) in zip([XY_COORDS,ZX_COORDS], colors)])

comp = make_edge( [color.green, color.orange])
comp.rotate( radians(-90), vec(0,0,1), vec(1.5,1.5,1.5))
comp.rotate( radians(180), vec(0,1,0), vec(1.5,1.5,1.5))

The error doesn't happen if I rotate comp radians(181) or don't do the first rotation. When I try to step through the program, sometimes the error does not occur.

Heidal

unread,
Aug 26, 2021, 8:46:51 PM8/26/21
to VPython-users
print(version) gives me ['7.6.2', 'jupyter'] and I'm using firefox

Heidal

unread,
Aug 26, 2021, 8:48:27 PM8/26/21
to VPython-users
Here's a file with the code that's experiencing the issue

On Thursday, August 26, 2021 at 5:45:17 PM UTC-7 Heidal wrote:
stripped_down.py

Heidal

unread,
Aug 26, 2021, 8:53:03 PM8/26/21
to VPython-users
tried to do a hack and get around it, the problem still shows up if you rotate radians(181) and then radians(-1)

Bruce Sherwood

unread,
Aug 30, 2021, 7:14:44 PM8/30/21
to VPython-users
When I run the program you posted first, I'm unable to see anything wrong. 

Here are prints of comp.pos and comp.axis for each of the three positions, which make sense:

<0.5, 0.5, 0.5> <1, 0, 0>
<0.5, 2.5, 0.5> <6.12323e-17, -1, 0>
<2.5, 2.5, 2.5> <-6.12323e-17, -1, -7.4988e-33>

In the final position the green quad is in the xy plane and the fold line is vertical.
The orange quad is on the right, in the xz plane. All of this looks correct.
Can you describe in more detail what you see? I inserted scene.pause() after
each step. I never see the configurations that are in the image you posted, which 
perhaps did not come from the code you posted first?

Bruce

Bruce Sherwood

unread,
Aug 30, 2021, 8:04:52 PM8/30/21
to VPython-users
Oops. Typo. The orange quad ends up in the yz plane. 

Bruce

--
You received this message because you are subscribed to a topic in the Google Groups "VPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vpython-users/P6TIkqUVrW8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vpython-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vpython-users/8a79db3b-11d1-4c5c-8206-6e0c0bc03fe8n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages