Applying texture to circle with cutout

29 views
Skip to first unread message

Stefan De Young

unread,
Jun 21, 2020, 12:34:28 AM6/21/20
to VPython-users
I'm trying to visualise the rings of Saturn. To do this, I have created an extrusion of a circle with a concentric circular cutout. The extrusion is of negligeable thickness since the rings are so thin compared to the radius of the planet. My issue arises when attempting to apply a texture to my extrusion.

#PLANET
saturn = sphere(pos=vector(0,0,0), texture='saturnmap.jpg', radius=1)

#RINGS
outer_circ = shapes.circle(radius=1.116*saturn.radius)
inner_circ = shapes.circle(radius=2.327*saturn.radius)
ring_thickness = 8.29e-6
expath = [vec(0,0,-ring_thickness/2), vec(0,0,ring_thickness/2)]

ex = extrusion(path=expath,shape=[outer_circ,inner_circ],texture='saturn_circle.png')

I have attempted to apply two textures:
1. A "radial" texture, which shows the colours of the rings starting at the inner diameter and moving radially outwards (ring color map from http://planetpixelemporium.com/saturn.html)
2. A "circular" texture, which is the radial texture from above which I have tiled (revolved) into a circle using inkscape

In both cases, the texture does not conform to the circular shape. Are there any options I can use in vpython in order to force the texture to apply in a circle? Alternatively, is there a way that I can format the texture image, so that it will apply correctly to my shape?

Thank you,

Stefan

Bruce Sherwood

unread,
Jun 21, 2020, 2:18:31 PM6/21/20
to VPython-users
I generated some rings like this:

scene.width = scene.height = 1000
for r in arange(0.1, 5, 0.1):
    c = color.hsv_to_rgb(vec(random(),1,1))
    ring(radius=r, thickness=0.02, axis=vec(0,0,1), color=c)
scene.pause()
scene.capture('rings')

It looks like this:


Then moved rings.png from Downloads to my program folder and executed this:

extrusion(path=[vec(0,0,0), vec(0,0,1)],
          shape=[shapes.circle(radius=10), shapes.circle(radius=5)],
          texture='rings.png')

It looks like this:


What I don't know is how to take an arbitrary image and manipulate its formatting. But my experience suggests that if you can find some way to display the image you want, in some app or other, you could capture that image and use it in the extrusion.

Bruce

Bruce Sherwood

unread,
Jun 21, 2020, 2:24:12 PM6/21/20
to VPython-users
(The colors of the visible rings differ in the two images because I remade one of them.)

Bruce

Bruce Sherwood

unread,
Jun 24, 2020, 8:20:12 PM6/24/20
to VPython-users
I should point out that another option is to use vertex/triangle/quad objects to create an arbitrary shape and patterning.

Bruce

Reply all
Reply to author
Forward
0 new messages