problems with circular extrusion

18 views
Skip to first unread message

Falky

unread,
Jul 3, 2024, 10:12:08 AM (2 days ago) Jul 3
to VPython-users
hello everyone, i am just experimented a bit with vpython and extrusions. i wanted to create an extrusion out of 5 segments in a shape of a circle. i also wanted it to be a bit radom everytime. Now it works but sometimes it is not a circle but an elipse. maybe someone can tell me what i am doing wrong. 

My Code:
import vpython as vp
import random as rd

i = 0
t = 5
pathv1 = vp.vec(rd.uniform(-t,t),rd.uniform(-t,t),i)

print(pathv1)
i = i+2
pathv2 = vp.vec(rd.uniform(-t,t),rd.uniform(-t,t),i)
print(pathv2)
i = i+2
pathv3 = vp.vec(rd.uniform(-t,t),rd.uniform(-t,t),i)
print(pathv3)
i = i+2
pathv4 = vp.vec(rd.uniform(-t,t),rd.uniform(-t,t),i)
print(pathv4)
i = i+2
pathv5 = vp.vec(rd.uniform(-t,t),rd.uniform(-t,t),i)
print(pathv5)
i = i+2
pathv6 = vp.vec(rd.uniform(-t,t),rd.uniform(-t,t),i)
print(pathv6)


myshape = vp.shapes.circle()
mypath = [ pathv1,pathv2,pathv3,pathv4,pathv5,pathv6]
paperclip = vp.extrusion(shape = myshape, path = mypath, color=vp.color.yellow)



while True: vp.rate(30)

John

unread,
Jul 3, 2024, 1:06:36 PM (2 days ago) Jul 3
to VPython-users
Maybe you can have a look at the vpython extrusions demo program for clues of what you might be doing wrong.


To see the source code for these extrusion shapes in the demo just click onView this program link.

John

Bruce Sherwood

unread,
Jul 3, 2024, 1:47:43 PM (2 days ago) Jul 3
to VPython-users
John, there really is something wrong with the extrusion object. I have no idea why the circle shape is sometimes rendered as an ellipse; I've never seen this effect before. The bug is seen in both the vpython module and in Web VPython.

Bruce

Falky

unread,
Jul 3, 2024, 4:29:33 PM (2 days ago) Jul 3
to VPython-users
it seems to depend on the first to vectors but i cannot confirm it 100%

Bruce Sherwood

unread,
Jul 4, 2024, 1:44:46 PM (21 hours ago) Jul 4
to VPython-users
Here is a minimal program that shows that the error does indeed occur when the first step in the path has both nonzero y and nonzero z components: 

from vpython import *
myshape = shapes.circle()
mypath = [vec(0,0,0), vec(0,-5,-2)]
extrusion(shape=myshape, path=mypath)

So it's definitely a bug in the extrusion object. The only way around this at the moment would seem to be to build the extrusion with a different orientation, then rotate it to the desired orientation.

Many thanks for reporting this problem!

Bruce
Reply all
Reply to author
Forward
0 new messages