- Frag Ingot
- |
- Senior Member
"Inveniam Viam Aut Facium" _~
if ( !now ){ when(); }
Posted by: Hylebos
So, I'm looking through a Python program that I'm supposed to modify tonight for an assignment due in my Computer Graphics class and I'm trying to understand how the code works. We're given a Parametric Surface viewer that has limited functionality, we're supposed to modify it so we can zoom in and out on the surface, rotate the camera around the surface, swap between parametric surfaces, lots of fun interesting stuff.
I'm currently looking through Tranforms.py, which has a lot of functions for transformations and matrix stuff, and this file extensively uses Numpy. However, I've run across some interesting notation used in several of the functions:def setMatrix(m1, m2):
m1[:,:] = m2What's up with the colons inside the brackets? I've never seen that sort of thing in any other language, and quick searches around the internet have proved fruitless. I can ask my professor later today what it means, but I figured I'd appeal to the Flood first.
Some more examples:
def setProjection(m,n,f,w,h):
m[:,:] = 0.0
m[0,0] = 2.0*n/w
m[1,1] = 2.0*n/h
m[2,2] = -(f+n)/(f-n)
m[2,3] = -2.0*f*n/(f-n)
m[3,2] = -1.0def setTranslation(m,x,y,z):
m[:,:] = N.eye(4, dtype=N.float32)
m[:,3] = (x,y,z,1)def setRotationY(m,angle):
s = N.sin(angle)
c = N.cos(angle)
m[:,:] = N.eye(4, dtype=N.float32)
m[0,0] = c
m[2,2] = c
m[0,2] = -s
m[2,0] = sThanks in advance for any help provided!All I could find was this. It looks like using the ':' is used to splice together arrays.. Hope this helps.
From what I can tell, it sets the entire arry to the value specified. So with an array of of ten a[10], if you go "a[:,:] = 0.0;" Then the array will be set with 0.0 for all ten nodes in the array. AFAIK
[Edited on 11.28.2012 11:16 AM PST]