From: <K.W...@gm...> - 2006-01-26 16:49:22
|
Hi, yesterday I tried again to figure out the right scale value and I failed again. I think I will wait until I know more about projection matrices and OpenGL before I try again. However, here is what I found out: If you call: gluPerspective(angle, aspect, near, far) P= glGetFloatv(GL_PROJECTION_MATRIX) then for all reasonable values of near and angle, it holds P(0,0,0) == (0,0,-1) P(tan_degree(angle/2)*aspect, 0,0) == (1,0,-1) P(0,tan_degree(angle/2),0) == (0,1,-1) I assumed here that tan interprets its arguments as degree, so using math.tan would involve some scaling. The right hand sides are results of the matrix-by-vector-multiplication. I used this function to do it, but I am not sure if it is the right way: def apply_matrix(A,v): if len(v)==3: v.append(1.) res=[] for zeile in A: res.append(sum([a*vi for (a,vi) in zip(zeile,v)])) if res[-1]!=0: for i in range(len(res)): res[i]= res[i]/res[-1] return res[:-1] I have no clue how to use the projection matrix to synchronize the mouse movement and the translation of the scene. I thought the view plane is perpendicular to the z-axis, its center being at z=-near, but since you said it's only a clipping parameter, I know I was wrong... ==== I spotted in the TODO file you'd like an orthogonal perspective, too. I think this would require a rewrite of the zoom function. Maybe using gluLookAt instead? And then the scale parameter of the pan function would be different, too. ==== What I like to do on Sunday, is to divide the clusterdisplay class into two classes, one for the window-handling (keyboard and mouse binding, reshaping,..) and one for drawing the data points, cluster centres etc. Please stop me if you don't want this. ==== One small change to trackball.py I comitted: Now gluPerspective is called at the program start and when resizing the window, too. Hope everything went right with svn. Regards, Karsten. -- Wikar -- der Desktop-Wiki: http://userpage.fu-berlin.de/~kweinert/wikar/ -- Telefonieren Sie schon oder sparen Sie noch? NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie |