rotate glumpy image "in place"

Skip to first unread message

Timothy Lillicrap

Mar 1, 2012, 1:44:40 PM3/1/12
to glumpy-users
Hi There,

I'm interested in rotating a glumpy image around its central point
rather than around the origin/z-axis.

I've tried to move the middle of the image to the origin, rotate it
there, and then move the object back to where I want it to be, but I'm
evidently doing something wrong as the image always ends up rotating
around the origin regardless of what I do.

It should be noted that I've managed to do exactly what I want for a
simple polygon I build myself with opengl calls. So, I roughly know
what I'm doing, but it's evident that my approach doesn't work because
the glumpy image object is a more complicated beast and can't be
treated quite like a simple opengl polygon.

Basically, I'm wondering if there is a way to do this easily without
getting into the internals of glumpy (Even then, I'm not quite sure
what to do - at one point I tried to do the Translate-to-origin/Rotate/
Translate-back stuff in the draw() function of the glumpy Image class,
but that also didn't seem to help).

Thanks for any help,


Nicolas Rougier

Mar 1, 2012, 2:16:27 PM3/1/12
to glumpy-users

This code may do what you want:

import numpy, glumpy
import OpenGL.GL as gl

fig = glumpy.figure( (512,512) )
Z = numpy.random.random((32,32)).astype(numpy.float32)
image = glumpy.image.Image(Z)

def on_draw():
gl.glTranslate(fig.width/2.0, fig.height/2.0,0)
image.draw( x=-fig.width/2, y=-fig.height/2, z=0,
width=fig.width, height=fig.height )


On Mar 1, 7:44 pm, Timothy Lillicrap <>

Timothy Lillicrap

Mar 2, 2012, 6:11:57 AM3/2/12
to glumpy-users
Yes, I managed to massage this into exactly what I want.

Thank you,

Reply all
Reply to author
0 new messages