Thanks a lot for the exam= ple. It helps me quite a bit however I am not sure how to do what I wish to= do. I attached to this email an example of what i would like to do.
On the left hand side is my original phase map data on a polar grid. I= want to make a polar to cartesian transformation of this phase map so it l= ooks like the middle plot in the figure attached, here the phase map is on = a cartesian grid. For this two first figures the grayscale cover -5 to 25 r= adians. Finally I want to wrap the phase data so the maximum grayscale valu= e is max 6.28 radians.

I managed to do the first step (polar to cartesian) usi= ng quad strip and texture mapping but i am not sure how I can get the verte= x value from the middle stage map as it is already a texture. I am certainl= y missing something but I can not see what.

On 6 No= vember 2011 05:23, Dirk Reiners wrote:

=A0 =A0 =A0 =A0Hi Brice,

On 11/05/2011 03:37 PM, Brice Thurin wrote:
Hi Dirk,

Thanks for your help. So if I understand properly, I first do the geometric= al
mapping to do the polar to cartesian transformation. Then I do the color ma= pping?

Yes and no. The actual mapping to color is done by the texture, you just ne= ed to feed your data into it in a way that puts the wraparound point at 0 a= nd 1.

I appended a simple example.

That's sound pretty neat to me.

It is! :) Its really cool, as you can mess with texture to show specific im= portant values or ranges, make it smooth or stepped (like in my example) an= d many other cool tricks.

Hope it helps

=A0 =A0 =A0 =A0Dirk

#!/usr/bin/python2.4
#
# Use texture for visualizating a data value.
#
# Based on texturedQuad.py by "Peter Roesch" <Peter.Roesch@fh-augsburg.d= e>
#
# Details are given in the file license.txt included in this distribution.<= br>
import sys
import array
import math

try:
=A0from OpenGL.GLUT import *
=A0from OpenGL.GL import *
=A0from OpenGL.GLU import *
except:
=A0print ''' Error PyOpenGL not installed properly !!''= ;'
=A0sys.exit( =A0)

def display( =A0):
=A0 =A0 =A0 =A0"""Glut display function."""<= br> =A0 =A0 =A0 =A0glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
=A0 =A0 =A0 =A0glColor3f( 1, 1, 1 )

=A0 =A0 =A0 =A0# Draw a regular grid
=A0 =A0 =A0 =A0gridres=3D40
=A0 =A0 =A0 =A0for y in [y * 1. / gridres - 0.5 for y in range(0, gridres)= ]:
=A0 =A0 =A0 =A0 =A0 =A0glBegin(GL_QUAD_STRIP)

=A0 =A0 =A0 =A0 =A0 =A0for x in [x * 1. / gridres - 0.5 for x in range(0, = gridres + 1)]:

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0# This is where the data value goes...
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0glTexCoord1f( math.sin(x*x + y*y) * 5 =A0)<= br> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0glVertex3f( x, y, 0 )

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0y1 =3D y + 1. / gridres
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0glTexCoord1f( math.sin(x*x + y1*y1) * 5 ) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0glVertex3f( x, y1, 0 )
=A0 =A0 =A0 =A0 =A0 =A0glEnd( =A0)

=A0 =A0 =A0 =A0glutSwapBuffers ( =A0)

def init( =A0):
=A0 =A0 =A0 =A0"""Glut init function."""

=A0 =A0 =A0 =A0glClearColor ( 0, 0, 0, 0 )
=A0 =A0 =A0 =A0glShadeModel( GL_SMOOTH )

=A0 =A0 =A0 =A0# Build texture. Just a trivial grey step one for now
=A0 =A0 =A0 =A0# For a real app you would create a nice lookup table
=A0 =A0 =A0 =A0nsteps =3D 8

=A0 =A0 =A0 =A0ns =3D 256/nsteps
=A0 =A0 =A0 =A0tmpList =3D [ int(i/ns)*ns for i in range(0, 256) ]
=A0 =A0 =A0 =A0texdata =3D array.array( 'B', tmpList ).tostring( )=
=A0 =A0 =A0 =A0texwidth =3D 256

=A0 =A0 =A0 =A0glTexParameterf( GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_REPEA= T )
=A0 =A0 =A0 =A0glTexParameterf( GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_L= INEAR )
=A0 =A0 =A0 =A0glTexParameterf( GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_L= INEAR )

=A0 =A0 =A0 =A0glTexImage1D( GL_TEXTURE_1D, 0, 3, texwidth, 0,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0GL_LUMINANCE, GL_UNSIGNED_BYTE,= texdata)
=A0 =A0 =A0 =A0glEnable( GL_TEXTURE_1D )

glutInit( sys.argv )
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB )
glutInitWindowSize( 250, 250 )
glutInitWindowPosition( 100, 100 )
glutCreateWindow( sys.argv[0] )
init( =A0)
glutDisplayFunc( display )
glutMainLoop( =A0)

--14dae934105389d70304b11431c6--